Module: OCG::Copyable

Included in:
OCG, Options
Defined in:
lib/ocg/copyable.rb

Overview

OCG::Copyable module.

Constant Summary collapse

VARIABLES_TO_COPY =
[].freeze

Instance Method Summary collapse

Instance Method Details

#initialize_copy(source) ⇒ Object

Initializes copy of source object using VARIABLES_TO_COPY keys.



10
11
12
13
14
15
16
17
# File 'lib/ocg/copyable.rb', line 10

def initialize_copy(source)
  self.class::VARIABLES_TO_COPY.each do |variable|
    key   = "@#{variable}".to_sym
    value = source.instance_variable_get key

    instance_variable_set key, value.dup
  end
end