Class: FixtureKit::Fixture
- Inherits:
-
Object
- Object
- FixtureKit::Fixture
- Includes:
- ConfigurationHelper
- Defined in:
- lib/fixture_kit/fixture.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #finish ⇒ Object
- #generate(force: false) ⇒ Object
-
#initialize(identifier, definition) ⇒ Fixture
constructor
A new instance of Fixture.
- #mount ⇒ Object
Constructor Details
#initialize(identifier, definition) ⇒ Fixture
Returns a new instance of Fixture.
11 12 13 14 15 16 17 18 19 |
# File 'lib/fixture_kit/fixture.rb', line 11 def initialize(identifier, definition) @identifier = identifier @definition = definition @cache = Cache.new(self) if definition.extends @parent = FixtureKit.runner.registry.add(definition.extends) end end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
9 10 11 |
# File 'lib/fixture_kit/fixture.rb', line 9 def cache @cache end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
9 10 11 |
# File 'lib/fixture_kit/fixture.rb', line 9 def definition @definition end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
9 10 11 |
# File 'lib/fixture_kit/fixture.rb', line 9 def identifier @identifier end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/fixture_kit/fixture.rb', line 9 def parent @parent end |
Instance Method Details
#finish ⇒ Object
39 40 41 |
# File 'lib/fixture_kit/fixture.rb', line 39 def finish @cache.clear_memory if anonymous? end |
#generate(force: false) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/fixture_kit/fixture.rb', line 21 def generate(force: false) return if @cache.exists? && !force parent&.generate emit(:cache_save) emit(:cache_saved) { @cache.save } end |
#mount ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/fixture_kit/fixture.rb', line 30 def mount unless @cache.exists? raise FixtureKit::CacheMissingError, "Cache does not exist for fixture '#{identifier}'" end emit(:cache_mount) emit(:cache_mounted) { @cache.load } end |