Module: PoxPaginate::ActiveResource::XmlFormat

Defined in:
lib/pox_paginate/active_resource/xml_format.rb

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pox_paginate/active_resource/xml_format.rb', line 4

def self.included(mod)
  mod.module_eval do
    def decode_with_pagination_support(xml)
      deserialised_xml = decode_without_pagination_support(xml)
      root_attributes = ::ActiveSupport::XmlMini.root_node_attributes(xml)
      if root_attributes['type'] == "array" && root_attributes['current_page']
        RemoteCollection.create(root_attributes['current_page'], root_attributes['per_page'], root_attributes['total_entries']) do |pager|
          pager.replace deserialised_xml
        end
      else
        deserialised_xml
      end
    end
    alias_method_chain :decode, :pagination_support
  end
end