Class: Qrfy::Collection
- Inherits:
-
Object
- Object
- Qrfy::Collection
- Defined in:
- lib/qrfy/collection.rb
Overview
# Qrfy Collection
A way to abstract collection API responses.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data:, total:, next_cursor:, prev_cursor:) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(data:, total:, next_cursor:, prev_cursor:) ⇒ Collection
Returns a new instance of Collection.
10 11 12 13 14 15 |
# File 'lib/qrfy/collection.rb', line 10 def initialize(data:, total:, next_cursor:, prev_cursor:) @data = data @total = total @next_cursor = next_cursor @prev_cursor = prev_cursor end |
Class Method Details
.from_response(data, type:) ⇒ Object
18 19 20 |
# File 'lib/qrfy/collection.rb', line 18 def from_response(data, type:) data.map { |attrs| type.new(attrs) } end |