Module: SubRinterceptorExample

Includes:
RinterceptorExample
Included in:
TestRinterceptor
Defined in:
lib/rinterceptor_example.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RinterceptorExample

#rinter_after, #rinter_before

Methods included from Rinterceptor

included, #rinter_after, #rinter_around, #rinter_before, #rinter_skip?

Class Method Details

.rinter_after_include_class(base) ⇒ Object



29
30
31
# File 'lib/rinterceptor_example.rb', line 29

def self.rinter_after_include_class(base)
  p "after_include_class in SubRinterceptorExample"
end

.rinter_before_include_class(base) ⇒ Object



24
25
26
27
28
# File 'lib/rinterceptor_example.rb', line 24

def self.rinter_before_include_class(base)
  p "before_include_class in SubRinterceptorExample"
  #set interceptor rules of instance methods, the variable can also be defined in class before include this module 
  base.instance_variable_set(:@include_i_methods, {nil => [/^i2_/, /^i3_/], :handler_it => /^i1_/})
end

Instance Method Details

#rinter_handler_it_around(invocation) ⇒ Object



32
33
34
35
36
37
# File 'lib/rinterceptor_example.rb', line 32

def rinter_handler_it_around(invocation)
  p "instance handler_it around begin -- method: #{invocation.method}, args: #{invocation.args} in SubRinterceptorExample"
  result = invocation.invoke("inter", "ddddd")
  p "instance handler_it around end -- method: #{invocation.method}, args: #{invocation.args} in SubRinterceptorExample"
  result
end