Class: YoutrackOnRails::Responses::CollectionResponse

Inherits:
Base
  • Object
show all
Defined in:
lib/youtrack_on_rails/responses/collection_response.rb

Constant Summary

Constants inherited from Base

Base::SUCCESSFUL_RESPONSE_CODES

Instance Attribute Summary

Attributes inherited from Base

#code, #http_response, #xml

Instance Method Summary collapse

Methods inherited from Base

#cookie, #errors, #initialize, #success?

Constructor Details

This class inherits a constructor from YoutrackOnRails::Responses::Base

Instance Method Details

#process(&block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/youtrack_on_rails/responses/collection_response.rb', line 4

def process(&block)
  xml.xpath(xpath).map do |object_node|
    @attributes ||= object_node.attributes.keys

    hash = @attributes.each_with_object({}) do |attribute_key, _hash|
      _hash[attribute_key.underscore] = object_node[attribute_key]
    end

    block.call(hash, object_node) if block_given?

    Dish(hash)
  end
end