Skip to content

Commit

Permalink
Use class level persisted_attributes to generate instance persisted a…
Browse files Browse the repository at this point in the history
…ttributes.
  • Loading branch information
jnunemaker committed Nov 20, 2012
1 parent 1476963 commit b9a19c8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/toy/attributes.rb
Expand Up @@ -56,11 +56,10 @@ def attributes

def persisted_attributes
{}.tap do |attrs|
self.class.attributes.except('id').each do |name, attribute|
next if attribute.virtual?
value = attribute.to_store(read_attribute(attribute.name))
next if value.nil?
attrs[attribute.persisted_name] = value
self.class.persisted_attributes.each do |attribute|
if (value = attribute.to_store(read_attribute(attribute.name)))
attrs[attribute.persisted_name] = value
end
end
end
end
Expand Down

0 comments on commit b9a19c8

Please sign in to comment.