Method: ObjectShadow::MethodIntrospection.get_method

Defined in:
lib/object_shadow/method_introspection.rb

.get_method(object, target, method_name, unbind) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/object_shadow/method_introspection.rb', line 184

def get_method(object, target, method_name, unbind)
  case target
  when :self
    if unbind
      object.method(method_name).unbind()
    else
      object.method(method_name)
    end
  when :class
    if unbind
      object.class.method(method_name).unbind()
    else
      object.class.method(method_name)
    end
  when :instances
    object.instance_method(method_name)
  else
    Kernel.raise ArgumentError, "(ObjectShadow) target: must be one of [:self, :class, :instances]"
  end
rescue NameError
  nil
end