Module: Object::Composite
- Defined in:
- lib/fmap.rb
Instance Method Summary collapse
Instance Method Details
#fmap(&bl) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fmap.rb', line 3 def fmap(&bl) begin new_inst = self.clone rescue TypeError return self end new_inst.instance_variables.each do |iv_name| iv_val = new_inst.instance_variable_get(iv_name) fmapped_val = bl.call( iv_val.fmap(&bl) ) new_inst.instance_variable_set(iv_name, fmapped_val) end end |
#functor? ⇒ Boolean
17 18 19 |
# File 'lib/fmap.rb', line 17 def functor? true end |