Class: FactoryBotProfile::Subscription
- Inherits:
-
Object
- Object
- FactoryBotProfile::Subscription
- Defined in:
- lib/factory_bot_profile/subscription.rb
Instance Attribute Summary collapse
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
-
#initialize(stats) ⇒ Subscription
constructor
A new instance of Subscription.
- #subscribe ⇒ Object
- #unsubscribe ⇒ Object
Constructor Details
#initialize(stats) ⇒ Subscription
Returns a new instance of Subscription.
5 6 7 |
# File 'lib/factory_bot_profile/subscription.rb', line 5 def initialize(stats) @stats = stats end |
Instance Attribute Details
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
3 4 5 |
# File 'lib/factory_bot_profile/subscription.rb', line 3 def stats @stats end |
Instance Method Details
#subscribe ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/factory_bot_profile/subscription.rb', line 9 def subscribe @subscription = ActiveSupport::Notifications.subscribe( "factory_bot.run_factory", FactoryBotProfile::Subscriber.new(stats) ) self end |
#unsubscribe ⇒ Object
17 18 19 20 |
# File 'lib/factory_bot_profile/subscription.rb', line 17 def unsubscribe ActiveSupport::Notifications.unsubscribe(@subscription) if @subscription @subscription = nil end |