Class: Peon::Handler
- Inherits:
-
Object
- Object
- Peon::Handler
- Defined in:
- lib/peon/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.
-
#task ⇒ Object
Returns the value of attribute task.
-
#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.
5 6 7 8 9 10 11 12 |
# File 'lib/peon/handler.rb', line 5 def initialize(queue) @queue = queue @when = lambda { true } @sub = lambda {} @unsub = lambda {} @on = false @task = lambda {} end |
Instance Attribute Details
#on ⇒ Object
Returns the value of attribute on.
3 4 5 |
# File 'lib/peon/handler.rb', line 3 def on @on end |
#queue ⇒ Object
Returns the value of attribute queue.
3 4 5 |
# File 'lib/peon/handler.rb', line 3 def queue @queue end |
#sub ⇒ Object
Returns the value of attribute sub.
3 4 5 |
# File 'lib/peon/handler.rb', line 3 def sub @sub end |
#task ⇒ Object
Returns the value of attribute task.
3 4 5 |
# File 'lib/peon/handler.rb', line 3 def task @task end |
#unsub ⇒ Object
Returns the value of attribute unsub.
3 4 5 |
# File 'lib/peon/handler.rb', line 3 def unsub @unsub end |
#when ⇒ Object
Returns the value of attribute when.
3 4 5 |
# File 'lib/peon/handler.rb', line 3 def when @when end |
Instance Method Details
#check ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/peon/handler.rb', line 18 def check if should_sub? @sub.call unless @on @on = true else @unsub.call if @on @on = false end end |
#should_sub? ⇒ Boolean
14 15 16 |
# File 'lib/peon/handler.rb', line 14 def should_sub? @when.call end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/peon/handler.rb', line 28 def to_s "<handler queue=#{@queue} on=#{@on}>" end |