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.5 lib/buttercms/butter_collection.rb
buttercms-ruby-1.4 lib/buttercms/butter_collection.rb
buttercms-ruby-1.3.2 lib/buttercms/butter_collection.rb
buttercms-ruby-1.3.1 lib/buttercms/butter_collection.rb
buttercms-ruby-1.3.0 lib/buttercms/butter_collection.rb
buttercms-ruby-1.2.0 lib/buttercms/butter_collection.rb
buttercms-ruby-1.1.3 lib/buttercms/butter_collection.rb
buttercms-ruby-1.1.2 lib/buttercms/butter_collection.rb
buttercms-ruby-1.1.1 lib/buttercms/butter_collection.rb
buttercms-ruby-1.1.0 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.10 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.9 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.8 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.7 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.6 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.5 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.4 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.3 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.2 lib/buttercms/butter_collection.rb
buttercms-ruby-1.0.1 lib/buttercms/butter_collection.rb