Class: Enumex::Base
- Inherits:
-
Object
- Object
- Enumex::Base
- Defined in:
- lib/enumex/base.rb
Instance Attribute Summary collapse
-
#enumerator ⇒ Object
readonly
Returns the value of attribute enumerator.
-
#extenders ⇒ Object
readonly
Returns the value of attribute extenders.
Instance Method Summary collapse
Instance Attribute Details
#enumerator ⇒ Object (readonly)
Returns the value of attribute enumerator.
3 4 5 |
# File 'lib/enumex/base.rb', line 3 def enumerator @enumerator end |
#extenders ⇒ Object (readonly)
Returns the value of attribute extenders.
3 4 5 |
# File 'lib/enumex/base.rb', line 3 def extenders @extenders end |
Instance Method Details
#attach_to(enumerator, &block) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/enumex/base.rb', line 5 def attach_to(enumerator, &block) @enumerator = enumerator @block = block actions.empty? ? self : run end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/enumex/base.rb', line 16 def run actions.reset enumerator.each do |*args| actions.pre.extenders.any? {|ext| ext.execute(*args) } block.call(*args).tap do |result| actions.post.extenders.each {|ext| ext.execute(*args) } end end end |