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
- #deep_clone ⇒ Object
- #instance_variables_get(*keys) ⇒ Object
- #instance_variables_set(vars) ⇒ Object
- #meta_class ⇒ Object
- #tap {|_self| ... } ⇒ Object
Instance Method Details
#deep_clone ⇒ Object
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_class ⇒ Object
2 3 4 |
# File 'lib/core_ext/object/meta_class.rb', line 2 def (class << self; self; end) end |
#tap {|_self| ... } ⇒ Object
2 3 4 5 |
# File 'lib/core_ext/object/tap.rb', line 2 def tap yield self self end |