class Modification

Attributes

method_name[R]
receiver[R]

Public Class Methods

new(name, receiver, method_name, method_body) click to toggle source
Calls superclass method
# File lib/modifiers/modification.rb, line 2
def initialize(name, receiver, method_name, method_body)
  @name, @receiver, @method_name = name, receiver, method_name
  super() do
    define_method(method_name, &method_body)
    set_visibility
  end
end

Private Instance Methods

private?() click to toggle source
# File lib/modifiers/modification.rb, line 25
def private?
  receiver.private_method_defined?(method_name)
end
protected?() click to toggle source
# File lib/modifiers/modification.rb, line 21
def protected?
  receiver.protected_method_defined?(method_name)
end
set_visibility() click to toggle source
# File lib/modifiers/modification.rb, line 14
def set_visibility
  case
  when private? then private(method_name)
  when protected? then protected(method_name)
  end
end