Class: Xing::Serializers::List

Inherits:
Base
  • Object
show all
Defined in:
lib/xing/serializers/list.rb

Direct Known Subclasses

PagedList

Instance Method Summary collapse

Methods inherited from Base

#as_json_with_wrap, #root, #routes

Instance Method Details

#as_json_without_wrap(options = {}) ⇒ Object



24
25
26
27
28
# File 'lib/xing/serializers/list.rb', line 24

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

#item_serializer_classObject

Raises:

  • (NotImplementedError)


6
7
8
9
# File 'lib/xing/serializers/list.rb', line 6

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

#item_serializer_optionsObject



11
12
13
# File 'lib/xing/serializers/list.rb', line 11

def item_serializer_options
  {}
end


30
31
32
33
34
35
36
# File 'lib/xing/serializers/list.rb', line 30

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

Raises:

  • (NotImplementedError)


19
20
21
22
# File 'lib/xing/serializers/list.rb', line 19

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


15
16
17
# File 'lib/xing/serializers/list.rb', line 15

def template_link
  return nil
end