Sha256: 3bf22b5d6cfe68d474d2af7a72142068b0a55bbe84c45559c8d9c9d2f4b2187e

Contents?: true

Size: 431 Bytes

Versions: 3

Compression:

Stored size: 431 Bytes

Contents

module Kloudless
  class Collection
    include Enumerable

    def initialize(model, json)
      @model = model
      @json = json
    end

    def total
      @json["total"]
    end

    def count
      @json["count"]
    end

    def page
      @json["page"]
    end

    def objects
      @json["objects"]
    end

    def each
      @json["objects"].each do |attrs|
        yield @model.new(attrs)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kloudless-0.2.1 lib/kloudless/collection.rb
kloudless-0.2.0 lib/kloudless/collection.rb
kloudless-0.1.0 lib/kloudless/collection.rb