Class: FixtureKit::Definition
- Inherits:
-
Object
- Object
- FixtureKit::Definition
- Defined in:
- lib/fixture_kit/definition.rb
Instance Attribute Summary collapse
-
#exposed ⇒ Object
readonly
Returns the value of attribute exposed.
-
#extends ⇒ Object
readonly
Returns the value of attribute extends.
Instance Method Summary collapse
- #evaluate(context, parent: nil) ⇒ Object
- #expose(**records) ⇒ Object
-
#initialize(extends: nil, &definition) ⇒ Definition
constructor
A new instance of Definition.
- #path ⇒ Object
Constructor Details
#initialize(extends: nil, &definition) ⇒ Definition
Returns a new instance of Definition.
7 8 9 10 11 |
# File 'lib/fixture_kit/definition.rb', line 7 def initialize(extends: nil, &definition) @definition = definition @exposed = {} @extends = extends end |
Instance Attribute Details
#exposed ⇒ Object (readonly)
Returns the value of attribute exposed.
5 6 7 |
# File 'lib/fixture_kit/definition.rb', line 5 def exposed @exposed end |
#extends ⇒ Object (readonly)
Returns the value of attribute extends.
5 6 7 |
# File 'lib/fixture_kit/definition.rb', line 5 def extends @extends end |
Instance Method Details
#evaluate(context, parent: nil) ⇒ Object
17 18 19 20 |
# File 'lib/fixture_kit/definition.rb', line 17 def evaluate(context, parent: nil) context.singleton_class.prepend(mixin(parent)) context.instance_exec(&@definition) end |
#expose(**records) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/fixture_kit/definition.rb', line 22 def expose(**records) records.each do |name, record| if @exposed.key?(name) raise FixtureKit::DuplicateNameError, "Name #{name} already exposed" end @exposed[name] = record end end |
#path ⇒ Object
13 14 15 |
# File 'lib/fixture_kit/definition.rb', line 13 def path @definition.source_location.first end |