module WerckerAPI::APICollection

Public Class Methods

included(klass) click to toggle source
# File lib/wercker_api/api_collection.rb, line 3
def self.included(klass)
  klass.class_eval do
    include Enumerable

    private
    attr_accessor :collection
  end
end
new(collection = []) click to toggle source
# File lib/wercker_api/api_collection.rb, line 12
def initialize(collection = [])
  self.collection = collection.map { |item| item_klass.new(item) }
end

Public Instance Methods

each(&block) click to toggle source
# File lib/wercker_api/api_collection.rb, line 16
def each(&block)
  collection.each(&block)
end

Private Instance Methods

item_klass() click to toggle source
# File lib/wercker_api/api_collection.rb, line 22
def item_klass
  @klass ||= Kernel.const_get(self.class.name.sub(/Collection$/, ''))
end