Class: CypherBuilder::Field
- Inherits:
-
Object
- Object
- CypherBuilder::Field
- Defined in:
- lib/cypher_builder/field.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #aliased ⇒ Object
- #as_cypher(payload:, context:) ⇒ Object
-
#initialize(prefix = nil, name) ⇒ Field
constructor
A new instance of Field.
- #prefixed_name ⇒ Object
Constructor Details
#initialize(prefix = nil, name) ⇒ Field
Returns a new instance of Field.
9 10 11 |
# File 'lib/cypher_builder/field.rb', line 9 def initialize(prefix = nil, name) @prefix, @name = prefix, name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/cypher_builder/field.rb', line 7 def name @name end |
Instance Method Details
#aliased ⇒ Object
25 26 27 |
# File 'lib/cypher_builder/field.rb', line 25 def aliased sprintf('%s AS %s', prefixed_name, name) end |
#as_cypher(payload:, context:) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/cypher_builder/field.rb', line 13 def as_cypher(payload:, context:) if context.ancestor?(Return) && !context.ancestor?(Alias) aliased else prefixed_name end end |
#prefixed_name ⇒ Object
21 22 23 |
# File 'lib/cypher_builder/field.rb', line 21 def prefixed_name [@prefix, @name].compact.join('.') end |