Class: Aspect4r::Model::Advice

Inherits:
Object
  • Object
show all
Defined in:
lib/aspect4r/model/advice.rb

Constant Summary collapse

BEFORE =
1
AFTER =
2
AROUND =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, with_method, group, options = {}) ⇒ Advice

Returns a new instance of Advice.



11
12
13
14
15
16
# File 'lib/aspect4r/model/advice.rb', line 11

def initialize type, with_method, group, options = {}
  @type        = type
  @with_method = with_method
  @group       = group
  @options     = options
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



8
9
10
# File 'lib/aspect4r/model/advice.rb', line 8

def group
  @group
end

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'lib/aspect4r/model/advice.rb', line 9

def options
  @options
end

#typeObject

Returns the value of attribute type.



9
10
11
# File 'lib/aspect4r/model/advice.rb', line 9

def type
  @type
end

#with_methodObject

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

Returns:

  • (Boolean)


30
31
32
# File 'lib/aspect4r/model/advice.rb', line 30

def after?
  type == AFTER
end

#around?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/aspect4r/model/advice.rb', line 34

def around?
  type == AROUND
end

#before?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/aspect4r/model/advice.rb', line 22

def before?
  type == BEFORE and not options[:skip_if_false]
end

#before_filter?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/aspect4r/model/advice.rb', line 26

def before_filter?
  type == BEFORE and options[:skip_if_false]
end

#invoke(obj, *args) ⇒ Object



38
39
40
# File 'lib/aspect4r/model/advice.rb', line 38

def invoke obj, *args
  obj.send with_method, *args
end

#nameObject



18
19
20
# File 'lib/aspect4r/model/advice.rb', line 18

def name
  options[:name] || with_method
end