Sha256: 31c8109ca1889baaee32e2fe5b1630337b394f82c322453986fc381ac3028fe4
Contents?: true
Size: 563 Bytes
Versions: 1
Compression:
Stored size: 563 Bytes
Contents
module StreamElements class Collection attr_reader :data, :total def self.from_response(response, type:, name: nil) if name.nil? body = response.body else body = response.body[name] end new( data: body.map { |attrs| type.new(attrs) }, total: body.count, ) end def initialize(data:, total:) @data = data @total = total end def each(&block) data.each(&block) end def first data.first end def last data.last end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
streamelements-0.5.0 | lib/stream_elements/collection.rb |