Module: Medo::Support::Decorator
- Included in:
- TextTaskWriter::Decorators::ColorsDecorator, TextTaskWriter::Decorators::ColorsDecorator::TaskColors, TextTaskWriter::Decorators::NumbersDecorator, TextTaskWriter::Decorators::NumbersDecorator::TaskNumbers
- Defined in:
- lib/medo/support/decorator.rb
Overview
This module is intended to extend other (decorator) modules
Usage:
module MyDecorator
extend Support::Decorator
after_decorate do |arg1, arg2|
@arg1, @arg2 = arg1, arg2
...
end
#methods go here
end
decorated = Object.new
MyDecorator.decorate(decorate, :foo, :bar)
:foo and :bar go to after_decorate block, which is evaluated on decorated object
after_update block is optional
Instance Method Summary collapse
Instance Method Details
#after_decorate(&block) ⇒ Object
35 36 37 |
# File 'lib/medo/support/decorator.rb', line 35 def after_decorate(&block) @after_decorate_block = block end |
#decorate(base, *args) ⇒ Object
29 30 31 32 33 |
# File 'lib/medo/support/decorator.rb', line 29 def decorate(base, *args) base.extend(self) base.instance_exec(*args, &@after_decorate_block) if defined? @after_decorate_block base end |