Sha256: e5918c71e1a8a3a7f84e17f280bf2ab31fcf4fb1561b8c63a37c4de974028833

Contents?: true

Size: 811 Bytes

Versions: 5

Compression:

Stored size: 811 Bytes

Contents

module MyApp
  class SongSerializer
    include RestPack::Serializer
    attributes :id, :title, :album_id
    can_include :albums, :artists
    can_filter_by :title
    can_sort_by :id, :title

    def title
      @context[:reverse_title?] ? @model.title.reverse : @model.title
    end
  end

  class AlbumSerializer
    include RestPack::Serializer
    attributes :id, :title, :year, :artist_id
    can_include :artists, :songs
    can_filter_by :year
  end

  class AlbumReviewSerializer
    include RestPack::Serializer
    attributes :message
    can_filter_by :album
  end

  class ArtistSerializer
    include RestPack::Serializer
    attributes :id, :name, :website
    can_include :albums, :songs, :fans
  end

  class FanSerializer
    include RestPack::Serializer
    attributes :id, :name
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
restpack_serializer-0.5.3 spec/fixtures/serializers.rb
restpack_serializer-0.5.2 spec/fixtures/serializers.rb
restpack_serializer-0.5.1 spec/fixtures/serializers.rb
restpack_serializer-0.5.0 spec/fixtures/serializers.rb
restpack_serializer-0.4.28 spec/fixtures/serializers.rb