Class: Aspect4r::Model::Advice
- Inherits:
-
Object
- Object
- Aspect4r::Model::Advice
- Defined in:
- lib/aspect4r/model/advice.rb
Constant Summary collapse
- BEFORE =
1
- AFTER =
2
- AROUND =
3
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#method_matcher ⇒ Object
Returns the value of attribute method_matcher.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
-
#with_method ⇒ Object
Returns the value of attribute with_method.
Instance Method Summary collapse
- #after? ⇒ Boolean
- #around? ⇒ Boolean
- #before? ⇒ Boolean
- #before_filter? ⇒ Boolean
-
#initialize(type, method_matcher, with_method, group, options = {}) ⇒ Advice
constructor
A new instance of Advice.
- #invoke(obj, *args, &block) ⇒ Object
- #name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type, method_matcher, with_method, group, options = {}) ⇒ Advice
Returns a new instance of Advice.
11 12 13 14 15 16 17 |
# File 'lib/aspect4r/model/advice.rb', line 11 def initialize type, method_matcher, with_method, group, = {} @type = type @method_matcher = method_matcher @with_method = with_method @group = group @options = end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
8 9 10 |
# File 'lib/aspect4r/model/advice.rb', line 8 def group @group end |
#method_matcher ⇒ Object
Returns the value of attribute method_matcher.
9 10 11 |
# File 'lib/aspect4r/model/advice.rb', line 9 def method_matcher @method_matcher end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/aspect4r/model/advice.rb', line 9 def @options end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/aspect4r/model/advice.rb', line 9 def type @type end |
#with_method ⇒ Object
Returns the value of attribute with_method.
9 10 11 |
# File 'lib/aspect4r/model/advice.rb', line 9 def with_method @with_method end |
Instance Method Details
#after? ⇒ Boolean
31 32 33 |
# File 'lib/aspect4r/model/advice.rb', line 31 def after? type == AFTER end |
#around? ⇒ Boolean
35 36 37 |
# File 'lib/aspect4r/model/advice.rb', line 35 def around? type == AROUND end |
#before? ⇒ Boolean
23 24 25 |
# File 'lib/aspect4r/model/advice.rb', line 23 def before? type == BEFORE and not [:skip_if_false] end |
#before_filter? ⇒ Boolean
27 28 29 |
# File 'lib/aspect4r/model/advice.rb', line 27 def before_filter? type == BEFORE and [:skip_if_false] end |
#invoke(obj, *args, &block) ⇒ Object
39 40 41 |
# File 'lib/aspect4r/model/advice.rb', line 39 def invoke obj, *args, &block obj.send with_method, *args, &block end |
#name ⇒ Object
19 20 21 |
# File 'lib/aspect4r/model/advice.rb', line 19 def name [:name] || with_method end |
#to_s ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/aspect4r/model/advice.rb', line 43 def to_s s = "<" << @group << "> " case @type when BEFORE if @options[:skip_if_false] s << "BEFORE_FILTER: " else s << "BEFORE: " end when AFTER s << "AFTER : " when AROUND s << "AROUND: " end s << "[" << @method_matcher.to_s << "] DO " s << @with_method.to_s s << " WITH OPTIONS " @options.each do |key, value| next if key == :skip_if_false s << key.to_s << ":" << value.to_s end s end |