Class: Cyrax::Presenters::DecoratedCollection

Inherits:
BaseCollection show all
Defined in:
lib/cyrax/presenters/decorated_collection.rb

Instance Attribute Summary

Attributes inherited from BaseCollection

#collection, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCollection

#as_json, #method_missing

Constructor Details

#initialize(collection, options = {}) ⇒ DecoratedCollection

Returns a new instance of DecoratedCollection.



3
4
5
6
7
8
# File 'lib/cyrax/presenters/decorated_collection.rb', line 3

def initialize(collection, options = {})
  super
  unless options[:decorator]
    raise "Decorator is not defined! Please define it with option :decorator"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cyrax::Presenters::BaseCollection

Class Method Details

.decorate(*args) ⇒ Object



14
15
16
# File 'lib/cyrax/presenters/decorated_collection.rb', line 14

def self.decorate(*args)
  new(*args).presented_collection
end

Instance Method Details

#presented_collectionObject



10
11
12
# File 'lib/cyrax/presenters/decorated_collection.rb', line 10

def presented_collection
  @decorated_collection ||= super.map {|item| decorate_item(item)}
end