Class: Parliament::Builder::OpenSearchResponseBuilder
- Inherits:
-
BaseResponseBuilder
- Object
- BaseResponseBuilder
- Parliament::Builder::OpenSearchResponseBuilder
- Defined in:
- lib/parliament/builder/open_search_response_builder.rb
Overview
OpenSearch response builder using Feedjira to parse the response.
Constant Summary collapse
- OPEN_SEARCH_ELEMENTS =
%w[totalResults Query startIndex itemsPerPage].freeze
Instance Method Summary collapse
-
#build ⇒ Object
Builds a Feedjira::Feed response.
Instance Method Details
#build ⇒ Object
Builds a Feedjira::Feed response. It adds the extra OpenSearch feed elements, then parses the HTTP Response.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/parliament/builder/open_search_response_builder.rb', line 10 def build OPEN_SEARCH_ELEMENTS.each do |element| Feedjira::Feed.add_common_feed_element(element) end # Add custom parser entries for hints Feedjira::Parser::AtomEntry.elements(:Name, as: :hint_types) # Custom parser for formatted link Feedjira::Parser::AtomEntry.element(:link, as: :formatted_url, value: :title) Feedjira::Feed.parse(@response.body) end |