Class: Alma::ResultSet
- Inherits:
-
Object
- Object
- Alma::ResultSet
- Extended by:
- Forwardable
- Includes:
- Error, Enumerable
- Defined in:
- lib/alma/result_set.rb
Direct Known Subclasses
BibItemSet, BibSet, CourseSet, FineSet, LibrarySet, LoanSet, LocationSet, RequestSet
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(response_body_hash) ⇒ ResultSet
constructor
A new instance of ResultSet.
- #loggable ⇒ Object
- #total_record_count ⇒ Object (also: #total_records)
Methods included from Error
#error, #error_message, #has_error?
Constructor Details
#initialize(response_body_hash) ⇒ ResultSet
Returns a new instance of ResultSet.
15 16 17 |
# File 'lib/alma/result_set.rb', line 15 def initialize(response_body_hash) @response = response_body_hash end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/alma/result_set.rb', line 10 def response @response end |
Instance Method Details
#each ⇒ Object
24 25 26 27 |
# File 'lib/alma/result_set.rb', line 24 def each @results ||= (@response.fetch(key, []) || []) .map { |item| single_record_class.new(item) } end |
#loggable ⇒ Object
19 20 21 22 |
# File 'lib/alma/result_set.rb', line 19 def loggable { uri: @response&.request&.uri&.to_s } .select { |k, v| !(v.nil? || v.empty?) } end |
#total_record_count ⇒ Object Also known as: total_records
29 30 31 |
# File 'lib/alma/result_set.rb', line 29 def total_record_count fetch("total_record_count", 0).to_i end |