test/fixtures/poro.rb in active_model_serializers-0.9.3 vs test/fixtures/poro.rb in active_model_serializers-0.9.4
- old
+ new
@@ -86,11 +86,11 @@
has_one :profile
end
class UserInfoSerializer < ActiveModel::Serializer
- has_one :user
+ has_one :user, serializer: UserSerializer
end
class ProfileSerializer < ActiveModel::Serializer
def description
description = object.read_attribute_for_serialization(:description)
@@ -106,9 +106,16 @@
has_many :posts
end
class PostSerializer < ActiveModel::Serializer
attributes :title, :body
+
+ def title
+ keyword = serialization_options[:highlight_keyword]
+ title = object.read_attribute_for_serialization(:title)
+ title = title.gsub(keyword,"'#{keyword}'") if keyword
+ title
+ end
has_many :comments
end
class SpecialPostSerializer < ActiveModel::Serializer