Class: ActiveCypher::Fixtures::DSLContext
- Inherits:
-
Object
- Object
- ActiveCypher::Fixtures::DSLContext
- Defined in:
- lib/active_cypher/fixtures/dsl_context.rb
Overview
Context for evaluating fixture profile DSL files. Provides node and relationship methods for use in profiles.
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#relationships ⇒ Object
readonly
Returns the value of attribute relationships.
Instance Method Summary collapse
-
#initialize ⇒ DSLContext
constructor
A new instance of DSLContext.
-
#node(ref, model_class, **props) ⇒ Object
DSL: node :ref, ModelClass, props.
-
#relationship(ref, from_ref, type, to_ref, **props) ⇒ Object
DSL: relationship :ref, :from_ref, :TYPE, :to_ref, props.
Constructor Details
#initialize ⇒ DSLContext
Returns a new instance of DSLContext.
10 11 12 13 14 |
# File 'lib/active_cypher/fixtures/dsl_context.rb', line 10 def initialize @nodes = [] @relationships = [] @refs = {} end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
8 9 10 |
# File 'lib/active_cypher/fixtures/dsl_context.rb', line 8 def nodes @nodes end |
#relationships ⇒ Object (readonly)
Returns the value of attribute relationships.
8 9 10 |
# File 'lib/active_cypher/fixtures/dsl_context.rb', line 8 def relationships @relationships end |
Instance Method Details
#node(ref, model_class, **props) ⇒ Object
DSL: node :ref, ModelClass, props
17 18 19 20 21 22 |
# File 'lib/active_cypher/fixtures/dsl_context.rb', line 17 def node(ref, model_class, **props) raise ArgumentError, "Duplicate node ref: #{ref.inspect}" if @refs.key?(ref) @refs[ref] = :node @nodes << { ref: ref, model_class: model_class, props: props } end |
#relationship(ref, from_ref, type, to_ref, **props) ⇒ Object
DSL: relationship :ref, :from_ref, :TYPE, :to_ref, props
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_cypher/fixtures/dsl_context.rb', line 25 def relationship(ref, from_ref, type, to_ref, **props) raise ArgumentError, "Duplicate relationship ref: #{ref.inspect}" if @refs.key?(ref) raise ArgumentError, "Unknown from_ref: #{from_ref.inspect}" unless @refs.key?(from_ref) raise ArgumentError, "Unknown to_ref: #{to_ref.inspect}" unless @refs.key?(to_ref) @refs[ref] = :relationship @relationships << { ref: ref, from_ref: from_ref, type: type, to_ref: to_ref, props: props } end |