class Cyrax::Presenters::DecoratedCollection
Public Class Methods
decorate(*args)
click to toggle source
# File lib/cyrax/presenters/decorated_collection.rb, line 14 def self.decorate(*args) new(*args).presented_collection end
new(collection, options = {})
click to toggle source
Calls superclass method
Cyrax::Presenters::BaseCollection::new
# 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
Public Instance Methods
presented_collection()
click to toggle source
Calls superclass method
Cyrax::Presenters::BaseCollection#presented_collection
# File lib/cyrax/presenters/decorated_collection.rb, line 10 def presented_collection @decorated_collection ||= super.map {|item| decorate_item(item)} end
Private Instance Methods
decorate_item(item)
click to toggle source
# File lib/cyrax/presenters/decorated_collection.rb, line 20 def decorate_item(item) options[:decorator].new(item) end