Sha256: 4cd78a4f8f79252cd7d18fa9c4eaa96dbf9a23560e475a64fec25fc97204433f

Contents?: true

Size: 514 Bytes

Versions: 1

Compression:

Stored size: 514 Bytes

Contents

module Burgundy
  class Collection
    include Enumerable

    def initialize(items, wrapping_class = nil)
      @items = items
      @wrapping_class = wrapping_class
    end

    def empty?
      !any?
    end

    def each(&block)
      to_ary.each(&block)
    end

    def to_ary
      @cache ||=  if @wrapping_class
                    @items.map {|item| @wrapping_class.new(item) }
                  else
                    @items.to_a
                  end
    end
    alias_method :to_a, :to_ary
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
burgundy-0.0.3 lib/burgundy/collection.rb