Class: Proc

Inherits:
Object show all
Defined in:
lib/dm-is-audited/is/audited.rb

Overview

overrides of Proc and Object to support calling blocks with context and parameters

Instance Method Summary collapse

Instance Method Details

#bind(object) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/dm-is-audited/is/audited.rb', line 15

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)
    method = instance_method(method_name)
    remove_method(method_name)
    method
  end.bind(object)
end