lib/burgundy/collection.rb in burgundy-0.2.0 vs lib/burgundy/collection.rb in burgundy-0.3.0

- old
+ new

@@ -1,21 +1,22 @@ module Burgundy - class Collection < SimpleDelegator - include Enumerable - + class Collection def initialize(items, wrapping_class = nil, *args) @items = items @wrapping_class = wrapping_class @args = args - __setobj__(@items) end - def each(&block) - to_ary.each(&block) + def method_missing(name, *args, &block) + to_ary.send(name, *args, &block) end + def respond_to?(name, include_all = false) + to_ary.respond_to?(name, include_all) + end + def to_ary - @cache ||= if @wrapping_class + @to_ary ||= if @wrapping_class @items.map {|item| @wrapping_class.new(item, *@args) } else @items.to_a end end