Sha256: 4eac6da41b4649a2b0511fa9a5ddb8ccc754e38393224a23e7b0e81b84fd0b7d
Contents?: true
Size: 992 Bytes
Versions: 3
Compression:
Stored size: 992 Bytes
Contents
module Alma class ResultSet def initialize(ws_response) @ws_response = ws_response end def total_record_count @ws_response[top_level_key].fetch('total_record_count', 0).to_i end def list @list ||= list_results end private def top_level_key raise NotImplementedError 'Subclasses of ResultSet Need to define the top level key' end def response_records_key raise NotImplementedError 'Subclasses of ResultSet Need to define the key for response records' end def response_records @ws_response[top_level_key].fetch(response_records_key,[]) end def list_results #If there is only one record in the response, HTTParty returns as a hash, not # an array of hashes, so wrap in array to normalize. response_array = (total_record_count == 1) ? [response_records] : response_records response_array.map do |record| Alma::AlmaRecord.new(record) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
alma-0.2.1 | lib/alma/result_set.rb |
alma-0.2.0 | lib/alma/result_set.rb |
alma-0.1.0 | lib/alma/result_set.rb |