Sha256: 103a2586b23fa4897b58dc74cbc74a2f85a9c814f99703e46015d09af9c6b37e

Contents?: true

Size: 542 Bytes

Versions: 1

Compression:

Stored size: 542 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)
    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

1 entries across 1 versions & 1 rubygems

Version Path
frenchy-0.0.9 lib/frenchy/collection.rb