aspect4r 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -59,6 +59,9 @@ Execution model: http://gcao.posterous.com/aspect4r-documentation-advice-executi
59
59
 
60
60
  See github issues http://github.com/gcao/aspect4r/issues
61
61
 
62
+ Experiment: change Base.included to define method_added and singleton_method_added. This will restrict
63
+ impact on the class that includes Aspect4r
64
+
62
65
  == Note on Patches/Pull Requests
63
66
 
64
67
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.2
1
+ 0.9.0
data/aspect4r.gemspec CHANGED
@@ -1,118 +1,115 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{aspect4r}
8
- s.version = "0.8.2"
8
+ s.version = "0.9.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Guoliang Cao"]
12
- s.date = %q{2010-07-01}
12
+ s.date = %q{2011-04-29}
13
13
  s.description = %q{AOP for ruby - use before, after and around to trim your fat methods and reduce code duplication}
14
14
  s.email = %q{gcao99@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "NOTES.rdoc",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "aspect4r.gemspec",
28
- "examples/advices_on_class_method_example.rb",
29
- "examples/after_example.rb",
30
- "examples/around_example.rb",
31
- "examples/before_example.rb",
32
- "examples/combined_example.rb",
33
- "examples/test_advices_example.rb",
34
- "lib/aspect4r.rb",
35
- "lib/aspect4r/after.rb",
36
- "lib/aspect4r/around.rb",
37
- "lib/aspect4r/base.rb",
38
- "lib/aspect4r/before.rb",
39
- "lib/aspect4r/classic.rb",
40
- "lib/aspect4r/errors.rb",
41
- "lib/aspect4r/extensions/module_extension.rb",
42
- "lib/aspect4r/helper.rb",
43
- "lib/aspect4r/model/advice.rb",
44
- "lib/aspect4r/model/advice_metadata.rb",
45
- "lib/aspect4r/model/advices_for_method.rb",
46
- "lib/aspect4r/model/aspect_data.rb",
47
- "lib/aspect4r/return_this.rb",
48
- "spec/aspect4r/advice_group_spec.rb",
49
- "spec/aspect4r/advice_on_class_method_spec.rb",
50
- "spec/aspect4r/advice_spec.rb",
51
- "spec/aspect4r/advice_test_spec.rb",
52
- "spec/aspect4r/advices_for_method_spec.rb",
53
- "spec/aspect4r/after_spec.rb",
54
- "spec/aspect4r/around_spec.rb",
55
- "spec/aspect4r/before_spec.rb",
56
- "spec/aspect4r/class_inheritance_spec.rb",
57
- "spec/aspect4r/classic_spec.rb",
58
- "spec/aspect4r/helper_spec.rb",
59
- "spec/aspect4r/include_advices_from_module_spec.rb",
60
- "spec/aspect4r/inheritance_inclusion_combined_spec.rb",
61
- "spec/aspect4r/method_added_spec.rb",
62
- "spec/aspect4r/module_inclusion_spec.rb",
63
- "spec/aspect4r/singleton_method_added_spec.rb",
64
- "spec/aspect4r/super_in_method_spec.rb",
65
- "spec/aspect4r_spec.rb",
66
- "spec/spec.opts",
67
- "spec/spec_helper.rb",
68
- "test/after_test.rb",
69
- "test/around_test.rb",
70
- "test/before_test.rb",
71
- "test/combined_test.rb",
72
- "test/method_invocation_test.rb",
73
- "test/test_helper.rb"
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "aspect4r.gemspec",
26
+ "examples/advices_on_class_method_example.rb",
27
+ "examples/after_example.rb",
28
+ "examples/around_example.rb",
29
+ "examples/before_example.rb",
30
+ "examples/combined_example.rb",
31
+ "examples/test_advices_example.rb",
32
+ "lib/aspect4r.rb",
33
+ "lib/aspect4r/after.rb",
34
+ "lib/aspect4r/around.rb",
35
+ "lib/aspect4r/base.rb",
36
+ "lib/aspect4r/before.rb",
37
+ "lib/aspect4r/classic.rb",
38
+ "lib/aspect4r/errors.rb",
39
+ "lib/aspect4r/helper.rb",
40
+ "lib/aspect4r/model/advice.rb",
41
+ "lib/aspect4r/model/advice_metadata.rb",
42
+ "lib/aspect4r/model/advices_for_method.rb",
43
+ "lib/aspect4r/model/aspect_data.rb",
44
+ "lib/aspect4r/return_this.rb",
45
+ "spec/aspect4r/advice_group_spec.rb",
46
+ "spec/aspect4r/advice_on_class_method_spec.rb",
47
+ "spec/aspect4r/advice_scope_spec.rb",
48
+ "spec/aspect4r/advice_spec.rb",
49
+ "spec/aspect4r/advice_test_spec.rb",
50
+ "spec/aspect4r/advices_for_method_spec.rb",
51
+ "spec/aspect4r/after_spec.rb",
52
+ "spec/aspect4r/around_spec.rb",
53
+ "spec/aspect4r/before_spec.rb",
54
+ "spec/aspect4r/class_inheritance_spec.rb",
55
+ "spec/aspect4r/classic_spec.rb",
56
+ "spec/aspect4r/helper_spec.rb",
57
+ "spec/aspect4r/include_advices_from_module_spec.rb",
58
+ "spec/aspect4r/inheritance_inclusion_combined_spec.rb",
59
+ "spec/aspect4r/method_added_spec.rb",
60
+ "spec/aspect4r/module_inclusion_spec.rb",
61
+ "spec/aspect4r/singleton_method_added_spec.rb",
62
+ "spec/aspect4r/super_in_method_spec.rb",
63
+ "spec/aspect4r_spec.rb",
64
+ "spec/spec.opts",
65
+ "spec/spec_helper.rb",
66
+ "test/after_test.rb",
67
+ "test/around_test.rb",
68
+ "test/before_test.rb",
69
+ "test/combined_test.rb",
70
+ "test/method_invocation_test.rb",
71
+ "test/test_helper.rb"
74
72
  ]
75
73
  s.homepage = %q{http://github.com/gcao/aspect4r}
76
- s.rdoc_options = ["--charset=UTF-8"]
77
74
  s.require_paths = ["lib"]
78
- s.rubygems_version = %q{1.3.7}
75
+ s.rubygems_version = %q{1.4.2}
79
76
  s.summary = %q{Aspect Oriented Programming for ruby}
80
77
  s.test_files = [
78
+ "examples/advices_on_class_method_example.rb",
79
+ "examples/after_example.rb",
80
+ "examples/around_example.rb",
81
+ "examples/before_example.rb",
82
+ "examples/combined_example.rb",
83
+ "examples/test_advices_example.rb",
81
84
  "spec/aspect4r/advice_group_spec.rb",
82
- "spec/aspect4r/advice_on_class_method_spec.rb",
83
- "spec/aspect4r/advice_spec.rb",
84
- "spec/aspect4r/advice_test_spec.rb",
85
- "spec/aspect4r/advices_for_method_spec.rb",
86
- "spec/aspect4r/after_spec.rb",
87
- "spec/aspect4r/around_spec.rb",
88
- "spec/aspect4r/before_spec.rb",
89
- "spec/aspect4r/class_inheritance_spec.rb",
90
- "spec/aspect4r/classic_spec.rb",
91
- "spec/aspect4r/helper_spec.rb",
92
- "spec/aspect4r/include_advices_from_module_spec.rb",
93
- "spec/aspect4r/inheritance_inclusion_combined_spec.rb",
94
- "spec/aspect4r/method_added_spec.rb",
95
- "spec/aspect4r/module_inclusion_spec.rb",
96
- "spec/aspect4r/singleton_method_added_spec.rb",
97
- "spec/aspect4r/super_in_method_spec.rb",
98
- "spec/aspect4r_spec.rb",
99
- "spec/spec_helper.rb",
100
- "test/after_test.rb",
101
- "test/around_test.rb",
102
- "test/before_test.rb",
103
- "test/combined_test.rb",
104
- "test/method_invocation_test.rb",
105
- "test/test_helper.rb",
106
- "examples/advices_on_class_method_example.rb",
107
- "examples/after_example.rb",
108
- "examples/around_example.rb",
109
- "examples/before_example.rb",
110
- "examples/combined_example.rb",
111
- "examples/test_advices_example.rb"
85
+ "spec/aspect4r/advice_on_class_method_spec.rb",
86
+ "spec/aspect4r/advice_scope_spec.rb",
87
+ "spec/aspect4r/advice_spec.rb",
88
+ "spec/aspect4r/advice_test_spec.rb",
89
+ "spec/aspect4r/advices_for_method_spec.rb",
90
+ "spec/aspect4r/after_spec.rb",
91
+ "spec/aspect4r/around_spec.rb",
92
+ "spec/aspect4r/before_spec.rb",
93
+ "spec/aspect4r/class_inheritance_spec.rb",
94
+ "spec/aspect4r/classic_spec.rb",
95
+ "spec/aspect4r/helper_spec.rb",
96
+ "spec/aspect4r/include_advices_from_module_spec.rb",
97
+ "spec/aspect4r/inheritance_inclusion_combined_spec.rb",
98
+ "spec/aspect4r/method_added_spec.rb",
99
+ "spec/aspect4r/module_inclusion_spec.rb",
100
+ "spec/aspect4r/singleton_method_added_spec.rb",
101
+ "spec/aspect4r/super_in_method_spec.rb",
102
+ "spec/aspect4r_spec.rb",
103
+ "spec/spec_helper.rb",
104
+ "test/after_test.rb",
105
+ "test/around_test.rb",
106
+ "test/before_test.rb",
107
+ "test/combined_test.rb",
108
+ "test/method_invocation_test.rb",
109
+ "test/test_helper.rb"
112
110
  ]
113
111
 
114
112
  if s.respond_to? :specification_version then
115
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
116
113
  s.specification_version = 3
117
114
 
118
115
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -3,8 +3,11 @@ require 'aspect4r/base'
3
3
  module Aspect4r
4
4
  module After
5
5
  def self.included(base)
6
- base.send(:include, Base::InstanceMethods)
7
- base.extend(Base::ClassMethods, ClassMethods)
6
+ base.send(:include, Base)
7
+ base.extend(ClassMethods)
8
+
9
+ eigen_class = class << base; self; end
10
+ eigen_class.extend(ClassMethods)
8
11
  end
9
12
 
10
13
  module ClassMethods
@@ -15,8 +18,11 @@ module Aspect4r
15
18
 
16
19
  module Classic
17
20
  def self.included(base)
18
- base.send(:include, Base::InstanceMethods)
19
- base.extend(Base::ClassMethods, ClassMethods)
21
+ base.send(:include, Base)
22
+ base.extend(ClassMethods)
23
+
24
+ eigen_class = class << base; self; end
25
+ eigen_class.extend(ClassMethods)
20
26
  end
21
27
 
22
28
  module ClassMethods
@@ -3,8 +3,11 @@ require 'aspect4r/base'
3
3
  module Aspect4r
4
4
  module Around
5
5
  def self.included(base)
6
- base.send(:include, Base::InstanceMethods)
7
- base.extend(Base::ClassMethods, ClassMethods)
6
+ base.send(:include, Base)
7
+ base.extend(ClassMethods)
8
+
9
+ eigen_class = class << base; self; end
10
+ eigen_class.extend(ClassMethods)
8
11
  end
9
12
 
10
13
  module ClassMethods
@@ -15,8 +18,11 @@ module Aspect4r
15
18
 
16
19
  module Classic
17
20
  def self.included(base)
18
- base.send(:include, Base::InstanceMethods)
19
- base.extend(Base::ClassMethods, ClassMethods)
21
+ base.send(:include, Base)
22
+ base.extend(ClassMethods)
23
+
24
+ eigen_class = class << base; self; end
25
+ eigen_class.extend(ClassMethods)
20
26
  end
21
27
 
22
28
  module ClassMethods
data/lib/aspect4r/base.rb CHANGED
@@ -7,14 +7,15 @@ require 'aspect4r/return_this'
7
7
 
8
8
  require 'aspect4r/helper'
9
9
 
10
- require 'aspect4r/extensions/module_extension'
11
-
12
10
  module Aspect4r
13
11
  module Base
14
12
  def self.included(base)
15
13
  base.send(:include, InstanceMethods)
16
14
  base.extend(ClassMethods)
17
- base.instance_variable_set('@a4r_data', Aspect4r::Model::AspectData.new(base))
15
+
16
+ eigen_class = class << base; self; end
17
+ eigen_class.send(:include, InstanceMethods)
18
+ eigen_class.extend(ClassMethods)
18
19
  end
19
20
 
20
21
  module InstanceMethods
@@ -23,7 +24,33 @@ module Aspect4r
23
24
  end
24
25
  end
25
26
 
26
- module ClassMethods
27
+ module ClassMethods
28
+ def method_added method
29
+ super method
30
+
31
+ return if method.to_s[0..2] == "a4r"
32
+
33
+ # save unbound method and create new method
34
+ if method_advices = a4r_data[method] and not Aspect4r::Helper.creating_method?
35
+ method_advices.wrapped_method = instance_method(method)
36
+ Aspect4r::Helper.create_method self, method
37
+ end
38
+ end
39
+
40
+ def singleton_method_added method
41
+ super method
42
+
43
+ return if method.to_s[0..2] == "a4r"
44
+
45
+ eigen_class = class << self; self; end
46
+
47
+ # save unbound method and create new method
48
+ if method_advices = eigen_class.a4r_data[method] and not Aspect4r::Helper.creating_method?
49
+ method_advices.wrapped_method = eigen_class.instance_method(method)
50
+ Aspect4r::Helper.create_method eigen_class, method
51
+ end
52
+ end
53
+
27
54
  def a4r_data
28
55
  @a4r_data ||= Aspect4r::Model::AspectData.new(self)
29
56
  end
@@ -3,8 +3,11 @@ require 'aspect4r/base'
3
3
  module Aspect4r
4
4
  module Before
5
5
  def self.included(base)
6
- base.send(:include, Base::InstanceMethods)
7
- base.extend(Base::ClassMethods, ClassMethods)
6
+ base.send(:include, Base)
7
+ base.extend(ClassMethods)
8
+
9
+ eigen_class = class << base; self; end
10
+ eigen_class.extend(ClassMethods)
8
11
  end
9
12
 
10
13
  module ClassMethods
@@ -19,8 +22,11 @@ module Aspect4r
19
22
 
20
23
  module Classic
21
24
  def self.included(base)
22
- base.send(:include, Base::InstanceMethods)
23
- base.extend(Base::ClassMethods, ClassMethods)
25
+ base.send(:include, Base)
26
+ base.extend(ClassMethods)
27
+
28
+ eigen_class = class << base; self; end
29
+ eigen_class.extend(ClassMethods)
24
30
  end
25
31
 
26
32
  module ClassMethods
@@ -5,8 +5,7 @@ require 'aspect4r/around'
5
5
  module Aspect4r
6
6
  module Classic
7
7
  def self.included(base)
8
- base.send(:include, Base::InstanceMethods)
9
- base.extend Base::ClassMethods, Before::Classic::ClassMethods, After::Classic::ClassMethods, Around::Classic::ClassMethods
8
+ base.send(:include, Before::Classic, After::Classic, Around::Classic)
10
9
  end
11
10
  end
12
11
  end
@@ -112,11 +112,7 @@ module Aspect4r
112
112
 
113
113
  <% if around_advice %>
114
114
  # around advice
115
- <% if around_advice.options[:method_name_arg] %>
116
- result = <%= around_advice.with_method %> '<%= method %>', wrapped_method, *args
117
- <% else %>
118
115
  result = <%= around_advice.with_method %> wrapped_method, *args
119
- <% end %>
120
116
  <% else %>
121
117
  # Invoke wrapped method
122
118
  result = wrapped_method.bind(self).call *args
data/lib/aspect4r.rb CHANGED
@@ -5,7 +5,6 @@ require 'aspect4r/classic'
5
5
 
6
6
  module Aspect4r
7
7
  def self.included(base)
8
- base.send(:include, Base::InstanceMethods)
9
- base.extend Base::ClassMethods, Before::ClassMethods, After::ClassMethods, Around::ClassMethods
8
+ base.send(:include, Before, After, Around)
10
9
  end
11
10
  end
@@ -3,9 +3,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
3
  describe "Advices on singleton method (also known as class method)" do
4
4
  it "class method" do
5
5
  class AdvicesOnClassMethod
6
+ include Aspect4r
7
+
6
8
  class << self
7
- include Aspect4r
8
-
9
+
9
10
  def value
10
11
  @value ||= []
11
12
  end
@@ -36,9 +37,10 @@ describe "Advices on singleton method (also known as class method)" do
36
37
 
37
38
  it "module singleton method" do
38
39
  module AdvicesOnModuleSingletonMethod
40
+ include Aspect4r
41
+
39
42
  class << self
40
- include Aspect4r
41
-
43
+
42
44
  def value
43
45
  @value ||= []
44
46
  end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Aspect4r do
4
+ it "should limit changes to module that includes Aspect4r" do
5
+ module ScopeParent
6
+ include Aspect4r
7
+ end
8
+
9
+ module ScopeChild
10
+ include ScopeParent
11
+ end
12
+
13
+ ScopeChild.methods.should_not include('a4r_data')
14
+ end
15
+ end
@@ -110,12 +110,12 @@ describe Aspect4r::Around do
110
110
  o.value.should == 'something'
111
111
  end
112
112
 
113
- it "should pass method name to advice block(or method) as first arg if method_name_arg is true" do
113
+ it "should be able to access method name through proxy.name (this subjects to change)" do
114
114
  s = nil
115
115
 
116
116
  @klass.class_eval do
117
- around :test, :method_name_arg => true do |method, proxy, value|
118
- s = method
117
+ around :test do |proxy, value|
118
+ s = proxy.name
119
119
  a4r_invoke proxy, value
120
120
  end
121
121
  end
@@ -3,12 +3,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
3
  describe "singleton_method_added" do
4
4
  it "should work if target method is defined after singleton_method_added and singleton_method_added calls super" do
5
5
  class AdvicesOnClassMethod1
6
+ include Aspect4r
7
+
6
8
  def self.singleton_method_added(method)
7
9
  super
8
10
  end
9
11
 
10
12
  class << self
11
- include Aspect4r
12
13
 
13
14
  def value
14
15
  @value ||= []
metadata CHANGED
@@ -2,12 +2,12 @@
2
2
  name: aspect4r
3
3
  version: !ruby/object:Gem::Version
4
4
  hash: 59
5
- prerelease: false
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 8
9
- - 2
10
- version: 0.8.2
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Guoliang Cao
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-01 00:00:00 -04:00
18
+ date: 2011-04-29 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -45,9 +45,7 @@ extra_rdoc_files:
45
45
  - README.rdoc
46
46
  files:
47
47
  - .document
48
- - .gitignore
49
48
  - LICENSE
50
- - NOTES.rdoc
51
49
  - README.rdoc
52
50
  - Rakefile
53
51
  - VERSION
@@ -65,7 +63,6 @@ files:
65
63
  - lib/aspect4r/before.rb
66
64
  - lib/aspect4r/classic.rb
67
65
  - lib/aspect4r/errors.rb
68
- - lib/aspect4r/extensions/module_extension.rb
69
66
  - lib/aspect4r/helper.rb
70
67
  - lib/aspect4r/model/advice.rb
71
68
  - lib/aspect4r/model/advice_metadata.rb
@@ -74,6 +71,7 @@ files:
74
71
  - lib/aspect4r/return_this.rb
75
72
  - spec/aspect4r/advice_group_spec.rb
76
73
  - spec/aspect4r/advice_on_class_method_spec.rb
74
+ - spec/aspect4r/advice_scope_spec.rb
77
75
  - spec/aspect4r/advice_spec.rb
78
76
  - spec/aspect4r/advice_test_spec.rb
79
77
  - spec/aspect4r/advices_for_method_spec.rb
@@ -103,8 +101,8 @@ homepage: http://github.com/gcao/aspect4r
103
101
  licenses: []
104
102
 
105
103
  post_install_message:
106
- rdoc_options:
107
- - --charset=UTF-8
104
+ rdoc_options: []
105
+
108
106
  require_paths:
109
107
  - lib
110
108
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -128,13 +126,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
126
  requirements: []
129
127
 
130
128
  rubyforge_project:
131
- rubygems_version: 1.3.7
129
+ rubygems_version: 1.4.2
132
130
  signing_key:
133
131
  specification_version: 3
134
132
  summary: Aspect Oriented Programming for ruby
135
133
  test_files:
134
+ - examples/advices_on_class_method_example.rb
135
+ - examples/after_example.rb
136
+ - examples/around_example.rb
137
+ - examples/before_example.rb
138
+ - examples/combined_example.rb
139
+ - examples/test_advices_example.rb
136
140
  - spec/aspect4r/advice_group_spec.rb
137
141
  - spec/aspect4r/advice_on_class_method_spec.rb
142
+ - spec/aspect4r/advice_scope_spec.rb
138
143
  - spec/aspect4r/advice_spec.rb
139
144
  - spec/aspect4r/advice_test_spec.rb
140
145
  - spec/aspect4r/advices_for_method_spec.rb
@@ -158,9 +163,3 @@ test_files:
158
163
  - test/combined_test.rb
159
164
  - test/method_invocation_test.rb
160
165
  - test/test_helper.rb
161
- - examples/advices_on_class_method_example.rb
162
- - examples/after_example.rb
163
- - examples/around_example.rb
164
- - examples/before_example.rb
165
- - examples/combined_example.rb
166
- - examples/test_advices_example.rb
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- test/output
data/NOTES.rdoc DELETED
@@ -1,42 +0,0 @@
1
- == TEST TODO
2
-
3
- Class inheritance
4
-
5
- Module inclusion
6
-
7
- Mix aspects in body and in module
8
-
9
- Mix aspects from multiple modules
10
-
11
- Mix aspects in body and inherited
12
-
13
- Mix aspects in body, inherited and in module
14
-
15
- == optimization idea
16
-
17
- On create method, define method as a place holder which will generate the real method on first execution
18
-
19
- == Inheritance / inclusion
20
-
21
- Automatically group aspects by the class/module that creates them
22
- Before aspects defined in base class run immediately before wrapped method
23
- After aspects run immediagely after
24
- Around aspects wrap around wrapped method
25
-
26
- Before aspects defined in module that are included at the beginning run before aspects from base class and after those in current class
27
- After aspects in module run after aspects from base class and before those in current class
28
- Around aspects in module wrap around wrapped method + before/after aspects in base class
29
-
30
- Before aspects defined in module that are included later run before all aspects already defined so far
31
- After aspects in module run after all aspects
32
- Around aspects in module wrap around wrapped method + before/after aspects
33
-
34
- == Clean up
35
-
36
- Reduce duplication in before/after/around.rb
37
-
38
- Include Aspect4r::Base in target module/class when a module with advices is included.
39
-
40
- Add included_with_a4r(for module) and inherited_with_a4r(for class) when Aspect4r::Base is included
41
-
42
- Rename class AspectForMethod, Definition etc.
@@ -1,39 +0,0 @@
1
- class Module
2
- def method_added_with_a4r(method)
3
- method_added_without_a4r(method)
4
-
5
- return if method.to_s =~ /a4r/
6
-
7
- # save unbound method and create new method
8
- if @a4r_data and method_advices = @a4r_data[method] and not Aspect4r::Helper.creating_method?
9
- method_advices.wrapped_method = instance_method(method)
10
- Aspect4r::Helper.create_method self, method
11
- end
12
- end
13
-
14
- alias method_added_without_a4r method_added
15
- alias method_added method_added_with_a4r
16
-
17
- def singleton_method_added_with_a4r(method)
18
- singleton_method_added_without_a4r(method)
19
-
20
- return if method.to_s =~ /a4r/
21
-
22
- # save unbound method and create new method
23
- eigen_class = instance_eval do
24
- class << self
25
- self
26
- end
27
- end
28
-
29
- my_advices = eigen_class.instance_variable_get(:@a4r_data)
30
-
31
- if my_advices and method_advices = my_advices[method] and not Aspect4r::Helper.creating_method?
32
- method_advices.wrapped_method = eigen_class.instance_method(method)
33
- Aspect4r::Helper.create_method eigen_class, method
34
- end
35
- end
36
-
37
- alias singleton_method_added_without_a4r singleton_method_added
38
- alias singleton_method_added singleton_method_added_with_a4r
39
- end