R
Rich Sturim
I need to build a string of all populated attributes of a given object.
I need to get the attribute name and it's value
Also,the object may have 10 attributes, but I'm only interested in the
attribute that are not nil.
here's a sample object:
foo = Foo.newbar => 'baz', :bar2 => 'baz2', :bar3 => 'baz3')
ultimately what I want is this as a string like this:
":bar => 'baz', :bar2 => 'baz2', :bar3 => 'baz3'"
code should be something like this? (sorry I'm a newbie)
s = ""
foo.instance_values.each do |v|
s += ":#{v.name} => #{v.value}"
end
s.split(",")
I need to get the attribute name and it's value
Also,the object may have 10 attributes, but I'm only interested in the
attribute that are not nil.
here's a sample object:
foo = Foo.newbar => 'baz', :bar2 => 'baz2', :bar3 => 'baz3')
ultimately what I want is this as a string like this:
":bar => 'baz', :bar2 => 'baz2', :bar3 => 'baz3'"
code should be something like this? (sorry I'm a newbie)
s = ""
foo.instance_values.each do |v|
s += ":#{v.name} => #{v.value}"
end
s.split(",")