Class: CoAspects::Attacher
- Inherits:
-
Object
- Object
- CoAspects::Attacher
- Defined in:
- lib/co_aspects/attacher.rb
Instance Method Summary collapse
- #add(method_name, options, block) ⇒ Object
- #attach(klass, method_name) ⇒ Object
-
#initialize ⇒ Attacher
constructor
A new instance of Attacher.
Constructor Details
#initialize ⇒ Attacher
Returns a new instance of Attacher.
5 6 7 |
# File 'lib/co_aspects/attacher.rb', line 5 def initialize @pending = [] end |
Instance Method Details
#add(method_name, options, block) ⇒ Object
9 10 11 12 |
# File 'lib/co_aspects/attacher.rb', line 9 def add(method_name, , block) aspect_class = aspect_from_method(method_name) @pending << Annotation.new(aspect_class, , block) end |
#attach(klass, method_name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/co_aspects/attacher.rb', line 14 def attach(klass, method_name) blocking do @pending.each do |pending| pending.aspect.apply klass, method: method_name, annotation: pending., block: pending.block end @pending = [] end end |