aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/proc.rb
blob: 5c29cc32a287c2560e2b3a017a9d66a86306ceff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
class Proc #:nodoc:
  def bind(object)
    block, time = self, Time.now
    (class << object; self end).class_eval do
      method_name = "__bind_#{time.to_i}_#{time.usec}"
      define_method(method_name, &block)     # define_method("__bind_1230458026_720454", &block)
      method = instance_method(method_name)  # method = instance_method("__bind_1230458026_720454")
      remove_method(method_name)             # remove_method("__bind_1230458026_720454")
      method
    end.bind(object)
  end
end