Sha256: e2eda8ab561a9faa89d6c1e75a79fa4b19a76271418e2fbc68a0b658fd629f3f

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module OData4
  class Query
    class Result
      # Represents the results of executing a OData4::Query.
      # @api private
      module Atom
        def process_results(&block)
          find_entities.each do |entity_xml|
            entity = OData4::Entity.from_xml(entity_xml, entity_options)
            block_given? ? block.call(entity) : yield(entity)
          end
        end

        def next_page
          result_xml.xpath("/feed/link[@rel='next']").first
        end

        def next_page_url
          next_page.attributes['href'].value.gsub(service.service_url, '')
        end

        def error_message
          result_xml.xpath('//error/message').first.andand.text
        end

        private

        def result_xml
          @result_xml ||= ::Nokogiri::XML(result.body).remove_namespaces!
        end

        # Find entity entries in a result set
        #
        # @return [Nokogiri::XML::NodeSet]
        def find_entities
          result_xml.xpath('//entry')
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
odata4-0.8.0 lib/odata4/query/result/atom.rb
odata4-0.7.0 lib/odata4/query/result/atom.rb