Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#attributes should work with ActiveRecord >= 3.1
  • Loading branch information
mguterl committed Jun 6, 2012
1 parent 359f585 commit e34725d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/serializable_attributes/schema.rb
Expand Up @@ -102,6 +102,12 @@ def reload(options = nil)
end
end

if ActiveRecord::VERSION::STRING >= '3.1'
@model.send(:define_method, :attributes) do
super.merge(send(data_field))
end
end

@model.send(:define_method, data_field) do
instance_variable_get("@#{data_field}") || begin
instance_variable_get("@#{changed_ivar}").clear if send("#{changed_ivar}?")
Expand Down

0 comments on commit e34725d

Please sign in to comment.