Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/reactive-core/ext/object.rb,
lib/reactive-core/ext/object_instance.rb
Instance Method Summary collapse
-
#with(*objects, &block) ⇒ Object
Runs the block for every object passed.
Instance Method Details
#with(*objects, &block) ⇒ Object
Runs the block for every object passed. Pass either a single object or a collection of objects (that must respond to #each) The block may accept a single argument or none. If it accepts one it is the object, if none, then the block is run in the context of the object (self is the object)
6 7 8 9 10 11 12 |
# File 'lib/reactive-core/ext/object.rb', line 6 def with(*objects, &block) if block.arity == 0 objects.each {|object| object.instance_eval(&block) } else objects.each {|object| yield object } end end |