Class: Seasar::Container::AspectInfoDef
- Inherits:
-
Object
- Object
- Seasar::Container::AspectInfoDef
- Defined in:
- lib/seasar/container/aspect-info-def.rb
Instance Attribute Summary collapse
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#interceptor ⇒ Object
Returns the value of attribute interceptor.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#pointcut ⇒ Object
Returns the value of attribute pointcut.
Instance Method Summary collapse
-
#applicable?(component_def) ⇒ Boolean
-
args 1.
-
-
#initialize(options) ⇒ AspectInfoDef
constructor
-
args 1.
-
-
#setup_matcher ⇒ Object
-
args - none - return - none.
-
Constructor Details
#initialize(options) ⇒ AspectInfoDef
-
args
-
Hash options
-
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/seasar/container/aspect-info-def.rb', line 27 def initialize() if [:interceptor].nil? raise ArgumentError.new("interceptor not specified.") end @interceptor = [:interceptor] if [:pattern].nil? @pattern = /interceptor/i @condition = false else @pattern = [:pattern] @condition = [:condition].nil? ? true : [:condition] end @pointcut = [:pointcut].nil? ? /.+/ : [:pointcut] self.setup_matcher end |
Instance Attribute Details
#condition ⇒ Object
Returns the value of attribute condition.
23 24 25 |
# File 'lib/seasar/container/aspect-info-def.rb', line 23 def condition @condition end |
#interceptor ⇒ Object
Returns the value of attribute interceptor.
23 24 25 |
# File 'lib/seasar/container/aspect-info-def.rb', line 23 def interceptor @interceptor end |
#pattern ⇒ Object
Returns the value of attribute pattern.
23 24 25 |
# File 'lib/seasar/container/aspect-info-def.rb', line 23 def pattern @pattern end |
#pointcut ⇒ Object
Returns the value of attribute pointcut.
23 24 25 |
# File 'lib/seasar/container/aspect-info-def.rb', line 23 def pointcut @pointcut end |
Instance Method Details
#applicable?(component_def) ⇒ Boolean
-
args
-
Seasar::Container::ComponentDef component_def
-
-
return
-
Boolean
-
84 85 86 87 88 89 90 91 |
# File 'lib/seasar/container/aspect-info-def.rb', line 84 def applicable?(component_def) result = @matcher.call(component_def) if @condition return result else return !result end end |
#setup_matcher ⇒ Object
-
args
-
none
-
-
return
-
none
-
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/seasar/container/aspect-info-def.rb', line 52 def setup_matcher case when @pattern.is_a?(Regexp) @matcher = lambda {|component_def| result = false if @pattern.match(component_def.component_name.to_s) result = true end if @pattern.match(component_def.component_class.name) result = true end result } when @pattern.is_a?(Class) @matcher = lambda {|component_def| component_def.component_class == @pattern } when @pattern.is_a?(Module) @matcher = lambda {|component_def| component_def.component_class.name.match(/^#{@pattern.name}::/) } when @pattern.is_a?(String) @matcher = lambda {|component_def| @pattern == component_def.component_name or @pattern == component_def.component_class.name } when @pattern.is_a?(Symbol) @matcher = lambda {|component_def| @pattern == component_def.component_name or @pattern == component_def.component_class.name.to_sym } else raise ArgumentError.new("unsupported pattern class #{@pattern}") end end |