Add AMS support to AR objects

This commit is contained in:
Santiago Pastorino
2013-07-04 11:17:53 -07:00
parent a25c352525
commit af357619c1
7 changed files with 47 additions and 2 deletions

24
test/fixtures/poro.rb vendored Normal file
View File

@@ -0,0 +1,24 @@
class Model
include ActiveModel::SerializerSupport
def initialize(hash={})
@attributes = hash
end
def read_attribute_for_serialization(name)
@attributes[name]
end
end
class ModelSerializer < ActiveModel::Serializer
attributes :attr1, :attr2
def attr2
attr2 = object.read_attribute_for_serialization(:attr2)
if scope
attr2 + '-' + scope
else
attr2
end
end
end