Method: MRuby::Command#clone

Defined in:
ext/enterprise_script_service/mruby/lib/mruby/build/command.rb

#cloneObject

clone is deep clone without @build



15
16
17
18
19
20
21
22
23
24
25
# File 'ext/enterprise_script_service/mruby/lib/mruby/build/command.rb', line 15

def clone
  target = super
  excepts = %w(@build)
  instance_variables.each do |attr|
    unless excepts.include?(attr.to_s)
      val = Marshal::load(Marshal.dump(instance_variable_get(attr))) # deep clone
      target.instance_variable_set(attr, val)
    end
  end
  target
end