Sha256: 92711eef5f5ff93e06b2e2e34ea4822785548aa55da850a846cefbf837fd068c
Contents?: true
Size: 614 Bytes
Versions: 10
Compression:
Stored size: 614 Bytes
Contents
module ActsAsIcontact class ResourceCollection < Enumerator attr_reader :total def initialize(klass, collection) @klass = klass @collection = collection[klass.collection_name] # Get number of elements @total = @collection.size enumcode = Proc.new do |yielder| counter = 0 while counter < @total yielder.yield klass.new(@collection[counter]) counter += 1 end end super(&enumcode) end def [](index) @klass.new(@collection[index]) if @collection[index] end end end
Version data entries
10 entries across 10 versions & 2 rubygems