Class: RHook::Invocation
Overview
The object contains the invocation information.
Instance Attribute Summary collapse
-
#args ⇒ Array<Object>
The arguments given to the method invocation.
-
#block ⇒ Proc
The block given to the method invocation.
-
#hint ⇒ Hash
Hint data given by RHookService#does / RHookService#to.
-
#hooks ⇒ Array<Hook>
readonly
(Internally used) The applied hooks on this invocation.
-
#receiver ⇒ Object
readonly
The receiver object of this method invocation.
-
#returned ⇒ Object
readonly
The returned value by the method invocation.
-
#target ⇒ Object
readonly
The target object that the hook is applied.
-
#target_proc ⇒ Proc
(Internally used) The procedure to execute the target method/procedure.
Instance Method Summary collapse
-
#proceed ⇒ Object
(also: #call)
Proceed to execute the next one on hooks-chain.
Instance Attribute Details
#args ⇒ Array<Object>
The arguments given to the method invocation.
282 283 284 |
# File 'lib/rhook.rb', line 282 def args @args end |
#block ⇒ Proc
The block given to the method invocation
282 283 284 |
# File 'lib/rhook.rb', line 282 def block @block end |
#hint ⇒ Hash
Hint data given by RHookService#does / RHookService#to.
282 283 284 |
# File 'lib/rhook.rb', line 282 def hint @hint end |
#hooks ⇒ Array<Hook> (readonly)
(Internally used) The applied hooks on this invocation.
282 283 284 |
# File 'lib/rhook.rb', line 282 def hooks @hooks end |
#receiver ⇒ Object (readonly)
The receiver object of this method invocation.
282 283 284 |
# File 'lib/rhook.rb', line 282 def receiver @receiver end |
#returned ⇒ Object (readonly)
The returned value by the method invocation. (Don’t set this. To change it, just return by the alternative value from the hook procedure.)
282 283 284 |
# File 'lib/rhook.rb', line 282 def returned @returned end |
#target ⇒ Object (readonly)
The target object that the hook is applied. (Usually same to #receiver)
282 283 284 |
# File 'lib/rhook.rb', line 282 def target @target end |
#target_proc ⇒ Proc
(Internally used) The procedure to execute the target method/procedure.
282 283 284 |
# File 'lib/rhook.rb', line 282 def target_proc @target_proc end |
Instance Method Details
#proceed ⇒ Object Also known as: call
Proceed to execute the next one on hooks-chain. If no more hooks, execute the target method/procedure.
290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/rhook.rb', line 290 def proceed hook = hooks[@hook_index] # -- If no more hook was found, calls target procedure and return hook or return self.returned = target_proc.call(*args, &block) # -- Set hook pointer to next, then call next hook @hook_index += 1 begin self.returned = hook.call(self) ensure @hook_index -= 1 end end |