Class: ButterCMS::ButterCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/buttercms/butter_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, json) ⇒ ButterCollection

Returns a new instance of ButterCollection.



7
8
9
10
11
12
13
# File 'lib/buttercms/butter_collection.rb', line 7

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

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



5
6
7
# File 'lib/buttercms/butter_collection.rb', line 5

def meta
  @meta
end

Instance Method Details

#each(&block) ⇒ Object



15
16
17
18
19
# File 'lib/buttercms/butter_collection.rb', line 15

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