Class: FixtureRecord::Cache
- Inherits:
-
Hash
- Object
- Hash
- FixtureRecord::Cache
- Defined in:
- lib/fixture_record/cache.rb
Instance Method Summary collapse
- #contains_class?(klass_or_string) ⇒ Boolean
- #contains_record?(record) ⇒ Boolean
- #dump! ⇒ Object
- #merge_data! ⇒ Object
- #prepare! ⇒ Object
Instance Method Details
#contains_class?(klass_or_string) ⇒ Boolean
10 11 12 13 |
# File 'lib/fixture_record/cache.rb', line 10 def contains_class?(klass_or_string) klass = klass_or_string.is_a?(String) ? klass_or_string.constantize : klass_or_string values.map(&:class).include?(klass) end |
#contains_record?(record) ⇒ Boolean
15 16 17 |
# File 'lib/fixture_record/cache.rb', line 15 def contains_record?(record) invert.key? record end |
#dump! ⇒ Object
4 5 6 7 8 |
# File 'lib/fixture_record/cache.rb', line 4 def dump! prepare! merge_data! FixtureRecord.data.write! end |
#merge_data! ⇒ Object
19 20 21 22 23 |
# File 'lib/fixture_record/cache.rb', line 19 def merge_data! self.each do |fixture_id, record| FixtureRecord.data.merge_record(record) end end |
#prepare! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/fixture_record/cache.rb', line 25 def prepare! self.values .each(&:filter_attributes_for_fxiture_record) .each(&:sanitize_attributes_for_fxiture_record) .each(&:update_belongs_to_fixture_record_associations) end |