Class: FactoryTrace::FixtureTracker
- Inherits:
-
Object
- Object
- FactoryTrace::FixtureTracker
- Defined in:
- lib/factory_trace/fixture_tracker.rb
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
-
#initialize ⇒ FixtureTracker
constructor
A new instance of FixtureTracker.
- #track! ⇒ Object
Constructor Details
#initialize ⇒ FixtureTracker
Returns a new instance of FixtureTracker.
7 8 9 |
# File 'lib/factory_trace/fixture_tracker.rb', line 7 def initialize @storage = {} end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
5 6 7 |
# File 'lib/factory_trace/fixture_tracker.rb', line 5 def storage @storage end |
Instance Method Details
#track! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/factory_trace/fixture_tracker.rb', line 11 def track! tracker_storage = @storage ::ActiveRecord::FixtureSet.prepend(Module.new do define_method(:[]) do |fixture_name| if fixture_name tracker_storage[name] ||= Set.new tracker_storage[name].add(fixture_name.to_s) end super(fixture_name) end end) end |