Class: ConvenientService::Utils::Object::GetOwnMethod

Inherits:
Support::Command show all
Defined in:
lib/convenient_service/utils/object/get_own_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(object, method_name, private: false) ⇒ GetOwnMethod

Returns a new instance of GetOwnMethod.

Parameters:

  • object (Object)

    Can be any type.

  • method_name (Symbol, String)
  • private (Boolean) (defaults to: false)


30
31
32
33
34
# File 'lib/convenient_service/utils/object/get_own_method.rb', line 30

def initialize(object, method_name, private: false)
  @object = object
  @method_name = method_name
  @private = private
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



17
18
19
# File 'lib/convenient_service/utils/object/get_own_method.rb', line 17

def method_name
  @method_name
end

#objectObject (readonly)

Returns the value of attribute object.



11
12
13
# File 'lib/convenient_service/utils/object/get_own_method.rb', line 11

def object
  @object
end

#privateObject (readonly)

Returns the value of attribute private.



23
24
25
# File 'lib/convenient_service/utils/object/get_own_method.rb', line 23

def private
  @private
end

Instance Method Details

#callClass

Returns:



44
45
46
47
48
49
50
# File 'lib/convenient_service/utils/object/get_own_method.rb', line 44

def call
  own_method = Utils::Module.get_own_instance_method(object.class, method_name, private: private)

  return unless own_method

  own_method.bind(object)
end