Class: Chronicles::Updater

Inherits:
Object
  • Object
show all
Defined in:
lib/chronicles/updater.rb

Overview

Reloads object method

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, name, code = nil) ⇒ Updater

Returns a new instance of Updater.



10
11
12
13
14
15
# File 'lib/chronicles/updater.rb', line 10

def initialize(object, name, code = nil)
  @object = object
  @name   = name
  @code   = code
  type
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



17
18
19
# File 'lib/chronicles/updater.rb', line 17

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/chronicles/updater.rb', line 17

def name
  @name
end

#objectObject (readonly)

Returns the value of attribute object.



17
18
19
# File 'lib/chronicles/updater.rb', line 17

def object
  @object
end

Instance Method Details

#klassObject



25
26
27
# File 'lib/chronicles/updater.rb', line 25

def klass
  object.singleton_class
end

#runObject



29
30
31
32
# File 'lib/chronicles/updater.rb', line 29

def run
  redefine_method
  protect_method
end

#typeObject



19
20
21
22
23
# File 'lib/chronicles/updater.rb', line 19

def type
  @type ||= %w(public private protected).detect do |item|
    object.public_send("#{ item }_methods").include? name
  end
end