Class: Minion::Handler
- Inherits:
-
Object
- Object
- Minion::Handler
- Defined in:
- lib/minion/handler.rb
Instance Attribute Summary collapse
-
#on ⇒ Object
Returns the value of attribute on.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#sub ⇒ Object
Returns the value of attribute sub.
-
#unsub ⇒ Object
Returns the value of attribute unsub.
-
#when ⇒ Object
Returns the value of attribute when.
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(queue) ⇒ Handler
constructor
A new instance of Handler.
- #should_sub? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(queue) ⇒ Handler
Returns a new instance of Handler.
4 5 6 7 8 9 10 |
# File 'lib/minion/handler.rb', line 4 def initialize(queue) @queue = queue @when = lambda { true } @sub = lambda {} @unsub = lambda {} @on = false end |
Instance Attribute Details
#on ⇒ Object
Returns the value of attribute on.
3 4 5 |
# File 'lib/minion/handler.rb', line 3 def on @on end |
#queue ⇒ Object
Returns the value of attribute queue.
3 4 5 |
# File 'lib/minion/handler.rb', line 3 def queue @queue end |
#sub ⇒ Object
Returns the value of attribute sub.
3 4 5 |
# File 'lib/minion/handler.rb', line 3 def sub @sub end |
#unsub ⇒ Object
Returns the value of attribute unsub.
3 4 5 |
# File 'lib/minion/handler.rb', line 3 def unsub @unsub end |
#when ⇒ Object
Returns the value of attribute when.
3 4 5 |
# File 'lib/minion/handler.rb', line 3 def when @when end |
Instance Method Details
#check ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/minion/handler.rb', line 16 def check if should_sub? @sub.call unless @on @on = true else @unsub.call if @on @on = false end end |
#should_sub? ⇒ Boolean
12 13 14 |
# File 'lib/minion/handler.rb', line 12 def should_sub? @when.call end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/minion/handler.rb', line 26 def to_s "<handler queue=#{@queue} on=#{@on}>" end |