aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/proc.rb
blob: 71b413a88a8b04278a279ce78f121ee00055cae4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
require "active_support/core_ext/object"

class Proc #:nodoc:
  def bind(object)
    block, time = self, Time.now
    object.class_eval do
      method_name = "__bind_#{time.to_i}_#{time.usec}"
      define_method(method_name, &block)
      method = instance_method(method_name)
      remove_method(method_name)
      method
    end.bind(object)
  end
end