Sha256: 3ebbdd96430049f3ecb8a934810c1ae473b5acc18bdbcb4fd606b90fea8ec59c

Contents?: true

Size: 551 Bytes

Versions: 19

Compression:

Stored size: 551 Bytes

Contents

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?

      decorator_class.decorate_collection(self, options)
    end

    # Compatbility for associations in draper
    def decorator_class
      return Frenchy::ArrayDecorator if none?

      "#{first.class.name}Decorator".constantize
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
frenchy-0.7.0 lib/frenchy/collection.rb
frenchy-0.6.3 lib/frenchy/collection.rb
frenchy-0.6.2 lib/frenchy/collection.rb
frenchy-0.6.1 lib/frenchy/collection.rb
frenchy-0.6.0 lib/frenchy/collection.rb
frenchy-0.5.2 lib/frenchy/collection.rb
frenchy-0.5.1 lib/frenchy/collection.rb
frenchy-0.5.0 lib/frenchy/collection.rb
frenchy-0.4.0 lib/frenchy/collection.rb
frenchy-0.3.0 lib/frenchy/collection.rb
frenchy-0.2.9 lib/frenchy/collection.rb
frenchy-0.2.8 lib/frenchy/collection.rb
frenchy-0.2.7 lib/frenchy/collection.rb
frenchy-0.2.6 lib/frenchy/collection.rb
frenchy-0.2.5 lib/frenchy/collection.rb
frenchy-0.2.4 lib/frenchy/collection.rb
frenchy-0.2.3 lib/frenchy/collection.rb
frenchy-0.2.2 lib/frenchy/collection.rb
frenchy-0.2.1 lib/frenchy/collection.rb