Class: CypherBuilder::Opt
- Inherits:
-
Object
- Object
- CypherBuilder::Opt
- Includes:
- Resolver
- Defined in:
- lib/cypher_builder/opt.rb
Instance Method Summary collapse
- #as_cypher(payload:, context:) ⇒ Object
-
#initialize(**params_and_parts) ⇒ Opt
constructor
A new instance of Opt.
Methods included from Resolver
Constructor Details
#initialize(**params_and_parts) ⇒ Opt
Returns a new instance of Opt.
9 10 11 |
# File 'lib/cypher_builder/opt.rb', line 9 def initialize(** params_and_parts) @params_and_parts = Hash[params_and_parts.map { |k, v| [k, wrap(v)] }] end |
Instance Method Details
#as_cypher(payload:, context:) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/cypher_builder/opt.rb', line 13 def as_cypher(payload:, context:) param, part = @params_and_parts.find { |k, _| payload.include?(k) } part = @params_and_parts.values.first unless part payload.already_used(param) if param resolve(part, payload: payload, context: context.add(self)) end |