Sha256: a675aa64e6d0c2cc575b9070121271af7b218133bae88eb9a2eb6c6552687dc1

Contents?: true

Size: 688 Bytes

Versions: 8

Compression:

Stored size: 688 Bytes

Contents

module RubyIsds
  module Responses
    module Messages
      class Collection < ::RubyIsds::Response
        attr_accessor :messages

        def initialize(response)
          super
          @messages = load_messages
          @status = ::RubyIsds::Responses::Dm::Status.new(parsed_body)
        end

        def load_messages
          return [] if results.blank?
          return [::RubyIsds::DataMessage.new(results)] if results.is_a?(Hash)
          results.map do |result|
            ::RubyIsds::DataMessage.new(result)
          end
        end

        private

        def results
          parsed_body['dmRecords'].try(:[], 'dmRecord')
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby_isds-0.13.0 lib/ruby_isds/responses/messages/collection.rb
ruby_isds-0.12.0 lib/ruby_isds/responses/messages/collection.rb
ruby_isds-0.11.1 lib/ruby_isds/responses/messages/collection.rb
ruby_isds-0.11.0 lib/ruby_isds/responses/messages/collection.rb
ruby_isds-0.10.5 lib/ruby_isds/responses/messages/collection.rb
ruby_isds-0.10.4 lib/ruby_isds/responses/messages/collection.rb
ruby_isds-0.10.3 lib/ruby_isds/responses/messages/collection.rb
ruby_isds-0.10.2 lib/ruby_isds/responses/messages/collection.rb