Class: RubyIsds::Responses::Messages::Collection

Inherits:
RubyIsds::Response show all
Defined in:
lib/ruby_isds/responses/messages/collection.rb

Instance Attribute Summary collapse

Attributes inherited from RubyIsds::Response

#body, #status

Instance Method Summary collapse

Methods inherited from RubyIsds::Response

#parsed_body, #result_key

Constructor Details

#initialize(response) ⇒ Collection

Returns a new instance of Collection.



7
8
9
10
11
# File 'lib/ruby_isds/responses/messages/collection.rb', line 7

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

Instance Attribute Details

#messagesObject

Returns the value of attribute messages.



5
6
7
# File 'lib/ruby_isds/responses/messages/collection.rb', line 5

def messages
  @messages
end

Instance Method Details

#load_messagesObject



13
14
15
16
17
18
19
# File 'lib/ruby_isds/responses/messages/collection.rb', line 13

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