class Peeek::Hook::Singleton

Constants

METHOD_PREFIX

Public Instance Methods

defined?() click to toggle source

Determine if the method is defined in the object.

@return whether the method is defined in the object

# File lib/peeek/hook/singleton.rb, line 23
def defined?
  @object.respond_to?(@method_name, true)
end
method_prefix() click to toggle source

@attribute [r] method_prefix @return [String] method prefix for singleton method. return always “.”

# File lib/peeek/hook/singleton.rb, line 10
def method_prefix
  METHOD_PREFIX
end
target_method() click to toggle source

@attribute [r] target_method @return [Method] the method of the object

# File lib/peeek/hook/singleton.rb, line 16
def target_method
  @object.method(@method_name)
end

Private Instance Methods

define_method(&block) click to toggle source
# File lib/peeek/hook/singleton.rb, line 48
def define_method(&block)
  singleton_class = class << @object; self end
  singleton_class.__send__(:define_method, @method_name, &block)
end