Class: Hijacker::Handler
- Inherits:
-
Object
- Object
- Hijacker::Handler
- Includes:
- DRb::DRbUndumped
- Defined in:
- lib/hijacker/handler.rb
Direct Known Subclasses
Constant Summary collapse
- @@handlers =
[]
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Class Method Summary collapse
Instance Method Summary collapse
- #handle(method, args, retval, raised, object) ⇒ Object
-
#initialize(opts) ⇒ Handler
constructor
A new instance of Handler.
Constructor Details
#initialize(opts) ⇒ Handler
Returns a new instance of Handler.
20 21 22 |
# File 'lib/hijacker/handler.rb', line 20 def initialize(opts) @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
19 20 21 |
# File 'lib/hijacker/handler.rb', line 19 def opts @opts end |
Class Method Details
.handlers ⇒ Object
53 54 55 |
# File 'lib/hijacker/handler.rb', line 53 def handlers @@handlers end |
.register_handler(handler) ⇒ Object
48 49 50 51 52 |
# File 'lib/hijacker/handler.rb', line 48 def register_handler(handler) handler.match(/handlers\/(\w+)/) handler = $1.strip if $1 @@handlers << handler end |
Instance Method Details
#handle(method, args, retval, raised, object) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hijacker/handler.rb', line 24 def handle(method, args, retval, raised, object) # Parameters received # # method :foo # # args [{:inspect => '3', :class => 'Fixnum'}, # {:inspect => '"string"', :class => 'String'}] # # retval {:inspect => ':bar', :class => 'Symbol'} # # - In case the method raised something, retval will be nil, # and the exception info will be available in raised: # # raised {:inspect => 'wrong number of arguments (0 for 2)', :class => 'ArgumentError'} # # object {:inspect => '#<MyClass:0x003457>', :class => 'MyClass'} # raise NotImplementedError.new("You are supposed to subclass Handler") end |