Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/aspect4r/extensions/module_extension.rb
Instance Method Summary collapse
- #included_with_a4r(base) ⇒ Object (also: #included)
- #method_added_with_a4r(method) ⇒ Object (also: #method_added)
- #singleton_method_added_with_a4r(method) ⇒ Object (also: #singleton_method_added)
Instance Method Details
#included_with_a4r(base) ⇒ Object Also known as: included
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/aspect4r/extensions/module_extension.rb', line 2 def included_with_a4r(base) included_without_a4r(base) return if @a4r_data.nil? or @a4r_data.empty? base.send(:include, Aspect4r) existing_aspects = base.a4r_data existing_aspects.methods_with_advices.merge(@a4r_data.methods_with_advices) end |
#method_added_with_a4r(method) ⇒ Object Also known as: method_added
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/aspect4r/extensions/module_extension.rb', line 16 def method_added_with_a4r(method) method_added_without_a4r(method) return if method.to_s =~ /a4r/ # save unbound method and create new method if @a4r_data and method_advices = @a4r_data[method] and not Aspect4r::Helper.creating_method? method_advices.wrapped_method = instance_method(method) Aspect4r::Helper.create_method self, method end end |
#singleton_method_added_with_a4r(method) ⇒ Object Also known as: singleton_method_added
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/aspect4r/extensions/module_extension.rb', line 31 def singleton_method_added_with_a4r(method) singleton_method_added_without_a4r(method) return if method.to_s =~ /a4r/ # save unbound method and create new method eigen_class = Aspect4r::Helper.eigen_class(self) my_advices = eigen_class.instance_variable_get(:@a4r_data) if my_advices and method_advices = my_advices[method] and not Aspect4r::Helper.creating_method? method_advices.wrapped_method = eigen_class.instance_method(method) Aspect4r::Helper.create_method eigen_class, method end end |