Class: MiniDecorator
- Inherits:
-
Module
- Object
- Module
- MiniDecorator
- Defined in:
- lib/mini_decorator.rb
Instance Method Summary collapse
-
#initialize(decorator) ⇒ MiniDecorator
constructor
A new instance of MiniDecorator.
Constructor Details
#initialize(decorator) ⇒ MiniDecorator
Returns a new instance of MiniDecorator.
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/mini_decorator.rb', line 2 def initialize(decorator) define_method(:decorate) do |property| if decorator.respond_to? property decorator.public_send(property, self) elsif self.respond_to? property self.public_send(property) else raise NoMethodError.new "No decorator or object method found for property: #{property}" end end end |