Sha256: ac8ee1d7d09738b88ffd776c177e8919f6211c2c78f3a3e1df7c4df59c2c1036

Contents?: true

Size: 597 Bytes

Versions: 1

Compression:

Stored size: 597 Bytes

Contents

module Frenchy
  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
    end

    # Compatbility for associations in draper
    def decorator_class
      "#{first.class.name}Decorator".constantize
    end

    # Backwards compatibility for old version of draper
    def nil?
      none?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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