Class: Lusnoc::Guard
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
Instance Method Summary collapse
- #condition(&block) ⇒ Object
-
#initialize(base_url) {|_self| ... } ⇒ Guard
constructor
A new instance of Guard.
- #run ⇒ Object
- #then(&block) ⇒ Object
Methods included from Helper
Constructor Details
#initialize(base_url) {|_self| ... } ⇒ Guard
Returns a new instance of Guard.
11 12 13 14 15 |
# File 'lib/lusnoc/guard.rb', line 11 def initialize(base_url) @base_url = base_url @callbacks = {} yield(self) if block_given? end |
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
9 10 11 |
# File 'lib/lusnoc/guard.rb', line 9 def callbacks @callbacks end |
Instance Method Details
#condition(&block) ⇒ Object
17 18 19 20 |
# File 'lib/lusnoc/guard.rb', line 17 def condition(&block) @callbacks[:condition] = block self end |
#run ⇒ Object
27 28 29 30 31 32 |
# File 'lib/lusnoc/guard.rb', line 27 def run th = start_thread yield ensure th.kill rescue nil end |
#then(&block) ⇒ Object
22 23 24 25 |
# File 'lib/lusnoc/guard.rb', line 22 def then(&block) @callbacks[:then] = block self end |