Class: Class
- Inherits:
-
Object
- Object
- Class
- Defined in:
- lib/mar/mar.rb
Instance Attribute Summary collapse
-
#mar_decorators ⇒ Object
Returns the value of attribute mar_decorators.
Instance Method Summary collapse
Instance Attribute Details
#mar_decorators ⇒ Object
Returns the value of attribute mar_decorators.
2 3 4 |
# File 'lib/mar/mar.rb', line 2 def mar_decorators @mar_decorators end |
Instance Method Details
#_(decorator) ⇒ Object
12 13 14 |
# File 'lib/mar/mar.rb', line 12 def _(decorator) mar_decorators << decorator end |
#clear_mar_decorators! ⇒ Object
8 9 10 |
# File 'lib/mar/mar.rb', line 8 def clear_mar_decorators! @mar_decorators = [] end |
#method_added(name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mar/mar.rb', line 16 def method_added(name) super decorators = mar_decorators clear_mar_decorators! if decorators.length > 0 new_name = "marrrrrrrr_#{name}" alias_method new_name, name define_method(name) { |*args, &outer_block| decorator = decorators[0] original = lambda{ |*decorator_args, &inner_block| self.send(new_name, *decorator_args, &inner_block) } decorator.call(original, *args, &outer_block) } end end |