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) ⇒ Object
- #add_wo_dups(method_name, *args) ⇒ Object
- #add_wo_dups_current(method_name, *args) ⇒ 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.
7 8 9 10 11 12 |
# File 'lib/eye/utils/celluloid_chain.rb', line 7 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.
54 55 56 |
# File 'lib/eye/utils/celluloid_chain.rb', line 54 def running @running end |
Instance Method Details
#add(method_name, *args) ⇒ Object
14 15 16 17 |
# File 'lib/eye/utils/celluloid_chain.rb', line 14 def add(method_name, *args) @calls << { method_name: method_name, args: args } ensure_process end |
#add_wo_dups(method_name, *args) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/eye/utils/celluloid_chain.rb', line 19 def add_wo_dups(method_name, *args) h = { method_name: method_name, args: args } if @calls[-1] != h @calls << h ensure_process end end |
#add_wo_dups_current(method_name, *args) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/eye/utils/celluloid_chain.rb', line 27 def add_wo_dups_current(method_name, *args) h = { method_name: method_name, args: args } if !@calls.include?(h) && @call != h @calls << h ensure_process end end |
#clear ⇒ Object Also known as: clear_pending_list
43 44 45 |
# File 'lib/eye/utils/celluloid_chain.rb', line 43 def clear @calls = [] end |
#inspect ⇒ Object
need, because of github.com/celluloid/celluloid/issues/22
50 51 52 |
# File 'lib/eye/utils/celluloid_chain.rb', line 50 def inspect "Celluloid::Chain(#{@target_class}: #{@calls.size})" end |
#list ⇒ Object
35 36 37 |
# File 'lib/eye/utils/celluloid_chain.rb', line 35 def list @calls end |
#names_list ⇒ Object
39 40 41 |
# File 'lib/eye/utils/celluloid_chain.rb', line 39 def names_list list.map { |el| el[:method_name].to_sym } end |