Sha256: 14aebebde7bbe3491faa539625617390f9831484b74ee310dc34837622e58e22

Contents?: true

Size: 853 Bytes

Versions: 13

Compression:

Stored size: 853 Bytes

Contents

require 'xing/serializers/base'

module Xing::Serializers
  class List < Base

    def item_serializer_class
      raise NotImplementedError,
        "subclasses of Xing::Serializers::List must override item_serializer_class to refer to the per-item serializer"
    end

    def item_serializer_options
      {}
    end

    def template_link
      return nil
    end

    def self_link
      raise NotImplementedError,
        "subclasses of Xing::Serializers::List must override self_link to return their own path"
    end

    def as_json_without_wrap(options={})
      object.map do |item|
        item_serializer_class.new(item, item_serializer_options).as_json
      end
    end

    def links
      links = {
        :self => self_link
      }
      links[:template] = template_link unless template_link.nil?
      return links
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
xing-backend-1.0.0.pre.beta lib/xing/serializers/list.rb
xing-backend-0.0.25 lib/xing/serializers/list.rb
xing-backend-0.0.23 lib/xing/serializers/list.rb
xing-backend-0.0.22 lib/xing/serializers/list.rb
xing-backend-0.0.21 lib/xing/serializers/list.rb
xing-backend-0.0.20 lib/xing/serializers/list.rb
xing-backend-0.0.19 lib/xing/serializers/list.rb
xing-backend-0.0.18 lib/xing/serializers/list.rb
xing-backend-0.0.17 lib/xing/serializers/list.rb
xing-backend-0.0.16 lib/xing/serializers/list.rb
xing-backend-0.0.15 lib/xing/serializers/list.rb
xing-backend-0.0.14 lib/xing/serializers/list.rb
xing-backend-0.0.13 lib/xing/serializers/list.rb