Class: Dominate::Instance

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/dominate/instance.rb

Instance Method Summary collapse

Constructor Details

#initialize(instance, locals = {}) ⇒ Instance

Returns a new instance of Instance.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dominate/instance.rb', line 30

def initialize instance, locals = {}
  instance.instance_variables.each do |name|
    instance_variable_set name, instance.instance_variable_get(name)
  end

  locals.to_h.each do |key, value|
    (class << self; self; end).send(:attr_accessor, key.to_sym)
    instance_variable_set("@#{key}", value)
  end

  super instance
end