Class: Proc
- Inherits:
-
Object
- Object
- Proc
- Defined in:
- lib/faraday_resource/base.rb
Overview
这个是一个给proc绑定一个object的方法
Instance Method Summary collapse
Instance Method Details
#call_with_obj(obj, *args) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/faraday_resource/base.rb', line 5 def call_with_obj(obj, *args) m = nil p = self Object.class_eval do define_method :a_temp_method_name, &p m = instance_method :a_temp_method_name; remove_method :a_temp_method_name end m.bind(obj).call(*args) end |