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.
5 6 7 |
# File 'lib/factory_trace/tracker.rb', line 5 def initialize @storage = {} end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
3 4 5 |
# File 'lib/factory_trace/tracker.rb', line 3 def storage @storage end |
Instance Method Details
#track! ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/factory_trace/tracker.rb', line 9 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 |