Sha256: 3e52d8ed973301821228b4e9370c7940dd519cd95c38af747dfe79eb3ecbf687

Contents?: true

Size: 391 Bytes

Versions: 21

Compression:

Stored size: 391 Bytes

Contents

module ButterCMS
  class ButterCollection
    include Enumerable

    attr_reader :meta

    def initialize(klass, json)
      data = json["data"]
      meta = json["meta"]

      @meta = HashToObject.convert(meta) if meta
      @items = data.map {|o| klass.new("data" => o) }
    end

    def each(&block)
      @items.each do |member|
        block.call(member)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
buttercms-ruby-1.0.0 lib/buttercms/butter_collection.rb