Class: ActiveCypher::Fixtures::Parser
- Inherits:
-
Object
- Object
- ActiveCypher::Fixtures::Parser
- Defined in:
- lib/active_cypher/fixtures/parser.rb
Overview
Parses a fixture profile file using instance_eval in a DSL context.
Instance Attribute Summary collapse
-
#dsl_context ⇒ Object
readonly
Returns the value of attribute dsl_context.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(file) ⇒ Parser
constructor
A new instance of Parser.
-
#parse ⇒ Object
Evaluates the profile file in the DSL context.
Constructor Details
#initialize(file) ⇒ Parser
Returns a new instance of Parser.
9 10 11 12 |
# File 'lib/active_cypher/fixtures/parser.rb', line 9 def initialize(file) @file = file @dsl_context = ActiveCypher::Fixtures::DSLContext.new end |
Instance Attribute Details
#dsl_context ⇒ Object (readonly)
Returns the value of attribute dsl_context.
7 8 9 |
# File 'lib/active_cypher/fixtures/parser.rb', line 7 def dsl_context @dsl_context end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/active_cypher/fixtures/parser.rb', line 7 def file @file end |
Instance Method Details
#parse ⇒ Object
Evaluates the profile file in the DSL context. Returns the DSLContext instance (which accumulates node/rel declarations).
16 17 18 19 20 |
# File 'lib/active_cypher/fixtures/parser.rb', line 16 def parse code = File.read(file) dsl_context.instance_eval(code, file) dsl_context end |