Module: Transproc::ClassTransformations
- Extended by:
- Functions
- Defined in:
- lib/transproc/class.rb
Overview
Transformation functions for Classes
Instance Method Summary collapse
-
#constructor_inject(*args, klass) ⇒ Object
Inject given arguments into the constructor of the class.
-
#set_ivars(ivar_hash, klass) ⇒ Object
Set instance variables from the hash argument (key/value pairs) on the object.
Methods included from Functions
Instance Method Details
#constructor_inject(*args, klass) ⇒ Object
Inject given arguments into the constructor of the class
29 30 31 |
# File 'lib/transproc/class.rb', line 29 def constructor_inject(*args, klass) klass.new(*args) end |
#set_ivars(ivar_hash, klass) ⇒ Object
Set instance variables from the hash argument (key/value pairs) on the object
44 45 46 47 48 49 50 |
# File 'lib/transproc/class.rb', line 44 def set_ivars(ivar_hash, klass) object = klass.allocate ivar_hash.each do |ivar_name, ivar_value| object.instance_variable_set("@#{ivar_name}", ivar_value) end object end |