In my code I call the first one (or rather, its analog, which takes a
hash) "Object#absorb" and would probably call the second one something
like "Object#soak_in".
class Object
def exude(*fields=self.instance_variables)
fields.collect_hash { |m| self.instance_variable_get( m ) }
end
def absorb(field_values)
field_values.each_pair { |k,v|
self.instance_variable_set( k,v )
}
end
def soak_in(field_values)
field_values.each.pair { |k,v| self.send( "#@{k}=", v ) }
end
end
WARNING: ABOVE CODE TYPED FROM MEMORY WITH A TODDLER'S HELP
class Object
def vulcan_mind_meld(field_values)
field_values.each_pair { |k,v|
if k.to_s[0..0] == '@'
self.instance_variable_set( k,v )
else
self.send( "#@{k}=", v ) }
end
end
end
WARNING: ABOVE CODE TYPED FROM MEMORY WITH A TODDLER'S HELP
Thanks MarkusQ!
T.
···
On Friday 10 September 2004 10:15 am, Markus wrote:
In my code I call the first one (or rather, its analog, which takes a
hash) "Object#absorb" and would probably call the second one something
like "Object#soak_in".
--
( o _
// trans.
/ \ transami@runbox.com
I don't give a damn for a man that can only spell a word one way.
-Mark Twain