adding a variable into the object
Here's now we dynamically add that variable/accessor on an already created object:
def tagList(item_list)
item_list.each do |item|
item.class.module_eval { attr_accessor :source_type}
item.source_type = some_source_type_A
done
itemlist
in our test.rb, we dump that just to show that it made it:
item_list=tagList(original_list)
item_list.each do |item|
puts "source type: #{item.source_type}")
done