Skip to content

Instantly share code, notes, and snippets.

@c7
Created April 29, 2010 13:50
Show Gist options
  • Save c7/383630 to your computer and use it in GitHub Desktop.
Save c7/383630 to your computer and use it in GitHub Desktop.
# Handle the data structures
[
['distributionevent', 'distribution_events', DistributionEvent],
['storage', 'storages', Storage]
].each do |name, accessor, structure_class|
data = product_data[name]
self.send("#{accessor}=", (!data.nil? && data.size > 0) ?
data.map { |d| structure_class.new d } : [])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment