Sha256: ef0fa8c8f2b05b9ea4e726b579c57300725b85005571b78cb57195e91b59ff52

Contents?: true

Size: 597 Bytes

Versions: 1

Compression:

Stored size: 597 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 ArtistSerializer
    include RestPack::Serializer
    attributes :id, :name, :website
    can_include :albums, :songs
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack_serializer-0.4.26 spec/fixtures/serializers.rb