Class: Decorator
- Inherits:
-
Object
- Object
- Decorator
- Defined in:
- lib/performance_promise/decorators.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.decorators ⇒ Object
Returns the value of attribute decorators.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(klass, method) ⇒ Decorator
constructor
A new instance of Decorator.
Constructor Details
#initialize(klass, method) ⇒ Decorator
83 84 85 |
# File 'lib/performance_promise/decorators.rb', line 83 def initialize(klass, method) @method = method end |
Class Attribute Details
.decorators ⇒ Object
Returns the value of attribute decorators.
64 65 66 |
# File 'lib/performance_promise/decorators.rb', line 64 def decorators @decorators end |
Class Method Details
.decorator_name(name) ⇒ Object
65 66 67 68 |
# File 'lib/performance_promise/decorators.rb', line 65 def decorator_name(name) Decorator.decorators ||= {} Decorator.decorators[name] = self end |
.inherited(klass) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/performance_promise/decorators.rb', line 71 def self.inherited(klass) name = klass.name.gsub(/^./) {|m| m.downcase} return if name =~ /^[^A-Za-z_]/ || name =~ /[^0-9A-Za-z_]/ MethodDecorators.module_eval " def \#{klass}(*args, &blk)\n decorate(\#{klass}, *args, &blk)\n end\n ruby_eval\nend\n", __FILE__, __LINE__ + 1 |