Class: PubSub::Register
- Inherits:
-
Object
- Object
- PubSub::Register
- Includes:
- Singleton
- Defined in:
- lib/pub_sub/register.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
Class Method Summary collapse
- .disable ⇒ Object
- .disabled? ⇒ Boolean
- .enable ⇒ Object
- .enabled? ⇒ Boolean
- .publish(*args, &block) ⇒ Object
- .subscribe(*args, &block) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Register
constructor
A new instance of Register.
Constructor Details
#initialize ⇒ Register
Returns a new instance of Register.
9 10 11 12 |
# File 'lib/pub_sub/register.rb', line 9 def initialize @enabled = true super end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
7 8 9 |
# File 'lib/pub_sub/register.rb', line 7 def enabled @enabled end |
Class Method Details
.disable ⇒ Object
19 20 21 |
# File 'lib/pub_sub/register.rb', line 19 def disable instance.enabled = false end |
.disabled? ⇒ Boolean
31 32 33 |
# File 'lib/pub_sub/register.rb', line 31 def disabled? !instance.enabled end |
.enable ⇒ Object
15 16 17 |
# File 'lib/pub_sub/register.rb', line 15 def enable instance.enabled = true end |
.enabled? ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'lib/pub_sub/register.rb', line 23 def enabled? if instance.enabled.nil? instance.enabled = true end instance.enabled end |
.publish(*args, &block) ⇒ Object
35 36 37 38 39 |
# File 'lib/pub_sub/register.rb', line 35 def publish(*args, &block) return if disabled? ActiveSupport::Notifications.publish(*args, &block) end |
.subscribe(*args, &block) ⇒ Object
41 42 43 |
# File 'lib/pub_sub/register.rb', line 41 def subscribe(*args, &block) ActiveSupport::Notifications.subscribe(*args, &block) end |