lib/frenchy/collection.rb in frenchy-0.0.8 vs lib/frenchy/collection.rb in frenchy-0.0.9

- old
+ new

@@ -1,24 +1,23 @@ module Frenchy + class ArrayDecorator + def self.decorate_collection(object, options={}) + object.to_a + end + end + class Collection < ::Array # Decorate the collection using the name of the decorator inferred by the first record def decorate(options={}) return self if none? - if decorator_class.respond_to?(:decorate_collection) - decorator_class.decorate_collection(self) - else - decorator_class.decorate(self) - end + decorator_class.decorate_collection(self) end # Compatbility for associations in draper def decorator_class - "#{first.class.name}Decorator".constantize - end + return Frenchy::ArrayDecorator if none? - # Backwards compatibility for old version of draper - def nil? - none? + "#{first.class.name}Decorator".constantize end end end