Sha256: 69527c91c6dbd1f708c0252a515f9311cdc85d5d21591aca6a933ce8565fc220

Contents?: true

Size: 337 Bytes

Versions: 7

Compression:

Stored size: 337 Bytes

Contents

class Proc

  # Bind a procedure to an object. This works
  # wrapping instance_eval on the Proc object
  # and then wrapping this in a new Proc.
  #
  #    a = [1,2,3]
  #    p1 = Proc.new{ join(' ') }
  #    p2 = p1.bind_to(a)
  #    p2.call  #=> '1 2 3'
  #
  def bind_to(object)
    Proc.new{object.instance_eval(&self)}
  end

end

Version data entries

7 entries across 6 versions & 1 rubygems

Version Path
facets-2.9.3 lib/core/facets/proc/bind_to.rb
facets-2.9.2 lib/core/facets/proc/bind_to.rb
facets-2.9.2 src/core/facets/proc/bind_to.rb
facets-2.9.1 lib/core/facets/proc/bind_to.rb
facets-2.9.0 lib/core/facets/proc/bind_to.rb
facets-2.9.0.pre.2 lib/core/facets/proc/bind_to.rb
facets-2.9.0.pre.1 lib/core/facets/proc/bind_to.rb