Method: MemoWise::InternalAPI.method_visibility

Defined in:
lib/memo_wise/internal_api.rb

.method_visibility(target, method_name) ⇒ :private, ...

Returns visibility of an instance method defined on class target.

Parameters:

  • target (Class, Module)

    The class to which we are prepending MemoWise to provide memoization.

  • method_name (Symbol)

    Name of existing instance method find the visibility of.

Returns:

  • (:private, :protected, :public)

    Visibility of existing instance method of the class.

Raises:

  • ArgumentError Raises ArgumentError unless method_name is a Symbol corresponding to an existing instance method defined on klass.



160
161
162
163
164
165
166
167
168
169
170
# File 'lib/memo_wise/internal_api.rb', line 160

def self.method_visibility(target, method_name)
  if target.private_method_defined?(method_name)
    :private
  elsif target.protected_method_defined?(method_name)
    :protected
  elsif target.public_method_defined?(method_name)
    :public
  else
    raise ArgumentError, "#{method_name.inspect} must be a method on #{target}"
  end
end