Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/ruby_ext.rb
Instance Method Summary collapse
-
#extend_once(*mods) ⇒ Object
Does what its name says.
-
#include_once(*mods) ⇒ Object
Does what its name says.
-
#instance_variables_send(obj, force = false) ⇒ Object
(also: #ivs_send)
Sets all instance variables of an object to another.
Instance Method Details
#extend_once(*mods) ⇒ Object
Does what its name says
81 82 83 84 85 |
# File 'lib/ruby_ext.rb', line 81 def extend_once(*mods) mods.each do |mod| extend mod unless .ancestors.include? mod end end |
#include_once(*mods) ⇒ Object
Does what its name says
88 89 90 91 92 |
# File 'lib/ruby_ext.rb', line 88 def include_once(*mods) mods.each do |mod| include mod unless ancestors.include? mod end end |
#instance_variables_send(obj, force = false) ⇒ Object Also known as: ivs_send
Sets all instance variables of an object to another
if force is set to true, existing instance variables will be overwritten
70 71 72 73 74 75 76 77 |
# File 'lib/ruby_ext.rb', line 70 def instance_variables_send(obj, force=false) instance_variables.each do |v| if force or not obj.instance_variables.include? v obj.instance_variable_set(v, instance_variable_get(v)) end end obj end |