Class: FactoryTrace::Tracker
- Inherits:
-
Object
- Object
- FactoryTrace::Tracker
- Defined in:
- lib/factory_trace/tracker.rb
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
-
#initialize ⇒ Tracker
constructor
A new instance of Tracker.
- #track! ⇒ Object
Constructor Details
#initialize ⇒ Tracker
Returns a new instance of Tracker.
9 10 11 |
# File 'lib/factory_trace/tracker.rb', line 9 def initialize @storage = {} end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
7 8 9 |
# File 'lib/factory_trace/tracker.rb', line 7 def storage @storage end |
Instance Method Details
#track! ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/factory_trace/tracker.rb', line 13 def track! ActiveSupport::Notifications.subscribe("factory_bot.run_factory") do |_name, _start, _finish, _id, payload| name = payload[:name].to_s traits = payload[:traits].map(&:to_s) storage[name] ||= Set.new storage[name] |= traits end end |