Module: Artdeco::DecoratorMethods
- Included in:
- Decorator
- Defined in:
- lib/artdeco.rb
Instance Method Summary collapse
Instance Method Details
#decorate(model, *decorator_classes) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/artdeco.rb', line 9 def decorate model, *decorator_classes return nil if model.nil? return model.map{|m| decorate(m,*decorator_classes)} if model.respond_to?(:map) decorator_classes = @decorator_classes || default_decorator_class(model) if decorator_classes.empty? [decorator_classes].flatten.each{|dc|model.extend dc} h = self.h model.define_singleton_method(:h){h} model.extend DecoratorMethods model end |