Class: Frenchy::Collection

Inherits:
Array
  • Object
show all
Defined in:
lib/frenchy/collection.rb

Instance Method Summary collapse

Instance Method Details

#decorate(options = {}) ⇒ Object

Decorate the collection using the name of the decorator inferred by the first record



10
11
12
13
14
# File 'lib/frenchy/collection.rb', line 10

def decorate(options={})
  return self if none?

  decorator_class.decorate_collection(self, options)
end

#decorator_classObject

Compatbility for associations in draper



17
18
19
20
21
# File 'lib/frenchy/collection.rb', line 17

def decorator_class
  return Frenchy::ArrayDecorator if none?

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