Class: Enumerable::Elementor
Overview
Elementor
Elementor is a type of functor. Operations applied to it are routed to each element.
Instance Method Summary collapse
-
#initialize(elem_object, elem_method = nil) ⇒ Elementor
constructor
A new instance of Elementor.
- #instance_delegate ⇒ Object
- #instance_operator ⇒ Object
-
#method_missing(sym, *args, &blk) ⇒ Object
def ==(other) instance_delegate == other.instance_delegate && instance_operator == other.instance_operator end.
Constructor Details
#initialize(elem_object, elem_method = nil) ⇒ Elementor
Returns a new instance of Elementor.
183 184 185 186 |
# File 'lib/more/facets/elementor.rb', line 183 def initialize(elem_object, elem_method=nil) @elem_object = elem_object @elem_method = elem_method || :map end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &blk) ⇒ Object
def ==(other)
instance_delegate == other.instance_delegate &&
instance_operator == other.instance_operator
end
201 202 203 |
# File 'lib/more/facets/elementor.rb', line 201 def method_missing(sym,*args,&blk) @elem_object.send(@elem_method){ |x| x.send(sym,*args,&blk) } end |