Class: Fixtury::Definition
- Inherits:
-
Object
- Object
- Fixtury::Definition
- Extended by:
- Forwardable
- Includes:
- SchemaNode
- Defined in:
- lib/fixtury/definition.rb
Overview
A class that contains the definition of a fixture. It also maintains a list of it’s dependencies to allow for analysis of the fixture graph.
Constant Summary
Constants included from SchemaNode
Instance Attribute Summary collapse
-
#callable ⇒ Object
readonly
Returns the value of attribute callable.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
Instance Method Summary collapse
-
#acts_like_fixtury_definition? ⇒ Boolean
Indicates whether the Definition acts like a Fixtury definition.
-
#initialize(deps: [], **opts, &block) ⇒ Definition
constructor
Initializes a new Definition object.
Methods included from SchemaNode
#acts_like_fixtury_schema_node?, #add_child, #apply_options!, #first_ancestor?, #get, #get!, #inspect, #isolation_key, #schema_node_type, #structure
Constructor Details
#initialize(deps: [], **opts, &block) ⇒ Definition
Initializes a new Definition object.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fixtury/definition.rb', line 15 def initialize(deps: [], **opts, &block) super(**opts) @dependencies = Array(deps).each_with_object({}) do |d, deps| parsed_deps = Dependency.from(parent, d) parsed_deps.each do |dep| existing = deps[dep.accessor] raise ArgumentError, "Accessor #{dep.accessor} is already declared by #{existing.search}" if existing deps[dep.accessor] = dep end end @callable = block end |
Instance Attribute Details
#callable ⇒ Object (readonly)
Returns the value of attribute callable.
46 47 48 |
# File 'lib/fixtury/definition.rb', line 46 def callable @callable end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
46 47 48 |
# File 'lib/fixtury/definition.rb', line 46 def dependencies @dependencies end |
Instance Method Details
#acts_like_fixtury_definition? ⇒ Boolean
Indicates whether the Definition acts like a Fixtury definition.
34 35 36 |
# File 'lib/fixtury/definition.rb', line 34 def acts_like_fixtury_definition? true end |