Class: Memorium::AccessLevel

Inherits:
Object
  • Object
show all
Defined in:
lib/memorium/access_level.rb

Constant Summary collapse

PUBLIC =
:public
PRIVATE =
:private
PROTECTED =
:protected

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, method_name) ⇒ AccessLevel

Returns a new instance of AccessLevel.



8
9
10
11
12
13
# File 'lib/memorium/access_level.rb', line 8

def initialize(klass, method_name)
  @klass = klass
  @method_name = method_name

  @access_level = define_access_level
end

Instance Attribute Details

#access_levelObject (readonly)

Returns the value of attribute access_level.



6
7
8
# File 'lib/memorium/access_level.rb', line 6

def access_level
  @access_level
end

#klassObject (readonly)

Returns the value of attribute klass.



6
7
8
# File 'lib/memorium/access_level.rb', line 6

def klass
  @klass
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



6
7
8
# File 'lib/memorium/access_level.rb', line 6

def method_name
  @method_name
end

Instance Method Details

#apply_level(level, name) ⇒ Object



16
# File 'lib/memorium/access_level.rb', line 16

def apply_level(level, name) = klass.send(level, name)

#apply_or_copy(level, target_method_name) ⇒ Object



18
19
20
# File 'lib/memorium/access_level.rb', line 18

def apply_or_copy(level, target_method_name)
  level.nil? ? copy_to(target_method_name) : apply_level(level, target_method_name)
end

#copy_to(target_method_name) ⇒ Object



15
# File 'lib/memorium/access_level.rb', line 15

def copy_to(target_method_name) = apply_level access_level, target_method_name