Class: Object

Inherits:
BasicObject
Defined in:
lib/core_ext/object/tap.rb,
lib/core_ext/object/deep_clone.rb,
lib/core_ext/object/meta_class.rb,
lib/core_ext/object/instance_variables.rb

Instance Method Summary collapse

Instance Method Details

#deep_cloneObject



2
3
4
# File 'lib/core_ext/object/deep_clone.rb', line 2

def deep_clone
  Marshal::load(Marshal::dump(self))
end

#instance_variables_get(*keys) ⇒ Object



2
3
4
# File 'lib/core_ext/object/instance_variables.rb', line 2

def instance_variables_get(*keys)
  keys.inject({}) { |result, key| result[key] = instance_variable_get(:"@#{key}"); result }
end

#instance_variables_set(vars) ⇒ Object



6
7
8
# File 'lib/core_ext/object/instance_variables.rb', line 6

def instance_variables_set(vars)
  vars.each { |key, value| instance_variable_set(:"@#{key}", value) }
end

#meta_classObject



2
3
4
# File 'lib/core_ext/object/meta_class.rb', line 2

def meta_class
  (class << self; self; end)
end

#tap {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Object)

    the object that the method was called on



2
3
4
5
# File 'lib/core_ext/object/tap.rb', line 2

def tap
  yield self
  self
end