Class: Eye::Utils::CelluloidChain
- Inherits:
-
Object
- Object
- Eye::Utils::CelluloidChain
- Includes:
- Celluloid
- Defined in:
- lib/eye/utils/celluloid_chain.rb
Instance Attribute Summary collapse
-
#running ⇒ Object
readonly
Returns the value of attribute running.
Instance Method Summary collapse
- #add(method_name, *args, &block) ⇒ Object
- #add_wo_dups(method_name, *args, &block) ⇒ Object
- #clear ⇒ Object (also: #clear_pending_list)
-
#initialize(target) ⇒ CelluloidChain
constructor
A new instance of CelluloidChain.
-
#inspect ⇒ Object
need, because of github.com/celluloid/celluloid/issues/22.
- #list ⇒ Object
- #names_list ⇒ Object
Constructor Details
#initialize(target) ⇒ CelluloidChain
Returns a new instance of CelluloidChain.
6 7 8 9 10 |
# File 'lib/eye/utils/celluloid_chain.rb', line 6 def initialize(target) @target = target @calls = [] @running = false end |
Instance Attribute Details
#running ⇒ Object (readonly)
Returns the value of attribute running.
42 43 44 |
# File 'lib/eye/utils/celluloid_chain.rb', line 42 def running @running end |
Instance Method Details
#add(method_name, *args, &block) ⇒ Object
12 13 14 15 |
# File 'lib/eye/utils/celluloid_chain.rb', line 12 def add(method_name, *args, &block) @calls << {:method_name => method_name, :args => args, :block => block} async.process unless @running end |
#add_wo_dups(method_name, *args, &block) ⇒ Object
17 18 19 20 21 |
# File 'lib/eye/utils/celluloid_chain.rb', line 17 def add_wo_dups(method_name, *args, &block) h = {:method_name => method_name, :args => args, :block => block} @calls << h if @calls[-1] != h async.process unless @running end |
#clear ⇒ Object Also known as: clear_pending_list
31 32 33 |
# File 'lib/eye/utils/celluloid_chain.rb', line 31 def clear @calls = [] end |
#inspect ⇒ Object
need, because of github.com/celluloid/celluloid/issues/22
38 39 40 |
# File 'lib/eye/utils/celluloid_chain.rb', line 38 def inspect "Celluloid::Chain(#{@target.class}: #{@calls.inspect})" end |
#list ⇒ Object
23 24 25 |
# File 'lib/eye/utils/celluloid_chain.rb', line 23 def list @calls end |
#names_list ⇒ Object
27 28 29 |
# File 'lib/eye/utils/celluloid_chain.rb', line 27 def names_list list.map{|el| el[:method_name].to_sym } end |