activegraph
activegraph copied to clipboard
Writing custom getter ends up in stack level too deep error
Additional information which could be helpful if relevant to your issue:
Code example (inline, gist, or repo)
class Color
include Neo4j::ActiveNode
property :name, type: String
property :code, type: String
def code
"##{read_attribute(:code)}"
end
end
Runtime information:
c = Color.create(name: 'Red', code: 'ff0000')
or
c = Color.find_by(name: 'Red')
Ends up with
Traceback (most recent call last):
16: from app/models/color.rb:18:in `code'
15: from app/models/color.rb:18:in `code'
14: from app/models/color.rb:18:in `code'
13: from app/models/color.rb:18:in `code'
12: from app/models/color.rb:18:in `code'
11: from app/models/color.rb:18:in `code'
10: from app/models/color.rb:18:in `code'
9: from app/models/color.rb:18:in `code'
8: from app/models/color.rb:18:in `code'
7: from app/models/color.rb:18:in `code'
6: from app/models/color.rb:18:in `code'
5: from app/models/color.rb:18:in `code'
4: from app/models/color.rb:18:in `code'
3: from app/models/color.rb:18:in `code'
2: from app/models/color.rb:18:in `code'
1: from app/models/color.rb:18:in `code'
SystemStackError (stack level too deep)
this happens even if I replace read_attribute with self[:code] as below
def code
"##{self[:code]}"
end
I think read_attribute do same as calling the same method again and again as follows
def code
"##{code}"
end
Neo4j database version:
neo4j
gem version: 9.6.1
neo4j-core
gem version: 9.0.0