module Draper::Decoratable
Provides shortcuts to decorate objects directly, so you can do ‘@product.decorate` instead of `ProductDecorator.new(@product)`.
This module is included by default into ‘ActiveRecord::Base` and `Mongoid::Document`, but you’re using another ORM, or want to decorate plain old Ruby objects, you can include it manually.
Public Instance Methods
applied_decorators()
click to toggle source
The list of decorators that have been applied to the object.
@return [Array<Class>] ‘[]`
# File lib/draper/decoratable.rb, line 33 def applied_decorators [] end
decorate(options = {})
click to toggle source
Decorates the object using the inferred {#decorator_class}. @param [Hash] options
see {Decorator#initialize}
# File lib/draper/decoratable.rb, line 17 def decorate(options = {}) decorator_class.decorate(self, options) end
decorated?()
click to toggle source
Checks if this object is decorated.
@return [false]
# File lib/draper/decoratable.rb, line 46 def decorated? false end
decorated_with?(decorator_class)
click to toggle source
(see Decorator#decorated_with?
) @return [false]
# File lib/draper/decoratable.rb, line 39 def decorated_with?(decorator_class) false end
decorator_class()
click to toggle source
(see ClassMethods#decorator_class
)
# File lib/draper/decoratable.rb, line 22 def decorator_class self.class.decorator_class end
decorator_class?()
click to toggle source
# File lib/draper/decoratable.rb, line 26 def decorator_class? self.class.decorator_class? end