Class: Undo::Wrapper

Inherits:
SimpleDelegator
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/undo/wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, options = {}) ⇒ Wrapper

Returns a new instance of Wrapper.



9
10
11
12
13
14
15
16
# File 'lib/undo/wrapper.rb', line 9

def initialize(object, options = {})
  @object = object
  @mutator_methods = options.delete(:mutator_methods) || []
  @uuid = object.respond_to?(:uuid) ? object.uuid : options.fetch(:uuid)
  @options = options

  super object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



18
19
20
21
# File 'lib/undo/wrapper.rb', line 18

def method_missing(method, *args, &block)
  store if mutator_methods.include? method
  super method, *args, &block
end

Instance Attribute Details

#uuidObject (readonly)

Returns the value of attribute uuid.



7
8
9
# File 'lib/undo/wrapper.rb', line 7

def uuid
  @uuid
end