Class: SocialNetworking::Serializers::SharedItemSerializer
- Inherits:
-
Serializer
- Object
- Serializer
- SocialNetworking::Serializers::SharedItemSerializer
- Defined in:
- app/models/social_networking/serializers/shared_item_serializer.rb
Overview
Serializes Shared Item models.
Instance Attribute Summary
Attributes inherited from Serializer
Instance Method Summary collapse
Methods inherited from Serializer
Constructor Details
This class inherits a constructor from SocialNetworking::Serializers::Serializer
Instance Method Details
#to_serialized ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/social_networking/serializers/shared_item_serializer.rb', line 6 def to_serialized item = model.item return nil if item.nil? path = item.class.to_s.pluralize.underscore label = model.item_label || ActiveSupport::Inflector.demodulize(item.class).humanize { className: "SocialNetworking::SharedItem", id: model.id, participantId: item.participant_id, isAdmin: item.participant.is_admin, createdAt: model.created_at, createdAtRaw: model.created_at.to_i, templatePath: "/social_networking/templates/#{path}", isPublic: model.is_public, data: item.to_serialized, summary: "#{model.action_type} #{indefinite_articlerize(label)}" \ "#{model.is_public ? ": " + item.description : ""}", description: item.description, comments: CommentSerializer.from_collection(model.comments), likes: LikeSerializer.from_collection(model.likes) } end |