Class: ConvenientService::Utils::Module::GetOwnInstanceMethod Private

Inherits:
Support::Command
  • Object
show all
Includes:
Support::FiniteLoop
Defined in:
lib/convenient_service/utils/module/get_own_instance_method.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

Constant Summary

Constants included from Support::FiniteLoop

Support::FiniteLoop::MAX_ITERATION_COUNT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support::FiniteLoop

finite_loop

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(mod, method_name, private: false, max_iteration_count: Support::FiniteLoop::MAX_ITERATION_COUNT) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • mod (Class, Module)
  • method_name (String, Symbol)
  • private (Boolean) (defaults to: false)
  • max_iteration_count (Integer) (defaults to: Support::FiniteLoop::MAX_ITERATION_COUNT)

Since:

  • 1.0.0



45
46
47
48
49
50
# File 'lib/convenient_service/utils/module/get_own_instance_method.rb', line 45

def initialize(mod, method_name, private: false, max_iteration_count: Support::FiniteLoop::MAX_ITERATION_COUNT)
  @mod = mod
  @method_name = method_name
  @private = private
  @max_iteration_count = max_iteration_count
end

Instance Attribute Details

#max_iteration_countObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



36
37
38
# File 'lib/convenient_service/utils/module/get_own_instance_method.rb', line 36

def max_iteration_count
  @max_iteration_count
end

#method_nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



24
25
26
# File 'lib/convenient_service/utils/module/get_own_instance_method.rb', line 24

def method_name
  @method_name
end

#modObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



18
19
20
# File 'lib/convenient_service/utils/module/get_own_instance_method.rb', line 18

def mod
  @mod
end

#privateObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



30
31
32
# File 'lib/convenient_service/utils/module/get_own_instance_method.rb', line 30

def private
  @private
end

Instance Method Details

#callUnboundMethod?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (UnboundMethod, nil)

Since:

  • 1.0.0



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/convenient_service/utils/module/get_own_instance_method.rb', line 55

def call
  method = mod.instance_method(method_name) if has_own_instance_method?

  ##
  # TODO: Warn if exceeded.
  #
  finite_loop do
    break if method.nil?
    break if method.owner == mod

    method = method.super_method
  end

  method
end