Module: Padrino::Decorator::DecorateHelpers
- Defined in:
- lib/padrino-decorator/decorate_helpers.rb
Instance Method Summary collapse
Instance Method Details
#decorate(object, options = {}) {|decorator| ... } ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/padrino-decorator/decorate_helpers.rb', line 5 def decorate(object, = {}) if object.respond_to?(:first) return [] if object.empty? klass_name = "#{object.first.class.to_s.pluralize}Decorator" else klass_name = "#{object.class}Decorator" end klass = .fetch(:as) { klass_name.constantize } decorator = klass.new(object, self) yield decorator if block_given? decorator end |