Class: 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
- #add_wo_dups_current(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 11 |
# File 'lib/eye/utils/celluloid_chain.rb', line 6 def initialize(target) @target = target @calls = [] @running = false @target_class = @target.class end |
Instance Attribute Details
#running ⇒ Object (readonly)
Returns the value of attribute running.
53 54 55 |
# File 'lib/eye/utils/celluloid_chain.rb', line 53 def running @running end |
Instance Method Details
#add(method_name, *args, &block) ⇒ Object
13 14 15 16 |
# File 'lib/eye/utils/celluloid_chain.rb', line 13 def add(method_name, *args, &block) @calls << {:method_name => method_name, :args => args, :block => block} ensure_process end |
#add_wo_dups(method_name, *args, &block) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/eye/utils/celluloid_chain.rb', line 18 def add_wo_dups(method_name, *args, &block) h = {:method_name => method_name, :args => args, :block => block} if @calls[-1] != h @calls << h ensure_process end end |
#add_wo_dups_current(method_name, *args, &block) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/eye/utils/celluloid_chain.rb', line 26 def add_wo_dups_current(method_name, *args, &block) h = {:method_name => method_name, :args => args, :block => block} if !@calls.include?(h) && @call != h @calls << h ensure_process end end |
#clear ⇒ Object Also known as: clear_pending_list
42 43 44 |
# File 'lib/eye/utils/celluloid_chain.rb', line 42 def clear @calls = [] end |
#inspect ⇒ Object
need, because of github.com/celluloid/celluloid/issues/22
49 50 51 |
# File 'lib/eye/utils/celluloid_chain.rb', line 49 def inspect "Celluloid::Chain(#{@target_class}: #{@calls.size})" end |
#list ⇒ Object
34 35 36 |
# File 'lib/eye/utils/celluloid_chain.rb', line 34 def list @calls end |
#names_list ⇒ Object
38 39 40 |
# File 'lib/eye/utils/celluloid_chain.rb', line 38 def names_list list.map{|el| el[:method_name].to_sym } end |