Module: L43::Core::ObjectExtensions
- Defined in:
- lib/l43/core/object_extensions.rb
Instance Method Summary collapse
Instance Method Details
#instance_variables_set(*names, **from) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/l43/core/object_extensions.rb', line 8 def instance_variables_set(*names, **from) # check names.each do ivar = "@#{it}" raise InstanceVariableOverride, "must not override existing instance variable #{ivar}" if instance_variable_defined?(ivar) raise MissingValue, "must provide a value for instance variable #{ivar} in keyword args: #{from.inspect}" unless from.has_key?(it) end # execute names.each do ivar = "@#{it}" instance_variable_set(ivar, from[it]) end end |
#instance_variables_set!(*names, **from) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/l43/core/object_extensions.rb', line 25 def instance_variables_set!(*names, **from) # check names.each do ivar = "@#{it}" "must provide a value for instance variable #{ivar} in keyword args: #{from.inspect}" unless from.has_key?(it) end # execute names.each do ivar = "@#{it}" instance_variable_set(ivar, from[it]) end end |