Class: Mountapi::Route::Handler
- Inherits:
-
Object
- Object
- Mountapi::Route::Handler
- Defined in:
- lib/mountapi/route/handler.rb
Overview
The handler is called if the route match Handler data should be any string representation of callable
Instance Method Summary collapse
- #call(*params) ⇒ Object
- #callable=(callable) ⇒ Object
-
#initialize(callable) ⇒ Handler
constructor
A new instance of Handler.
- #raw_value ⇒ Object
Constructor Details
#initialize(callable) ⇒ Handler
6 7 8 |
# File 'lib/mountapi/route/handler.rb', line 6 def initialize(callable) self.callable = callable end |
Instance Method Details
#call(*params) ⇒ Object
24 25 26 |
# File 'lib/mountapi/route/handler.rb', line 24 def call(*params) @callable.call(*params) end |
#callable=(callable) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/mountapi/route/handler.rb', line 10 def callable=(callable) @callable ||= if callable.respond_to? :call callable elsif callable.kind_of?(String) eval(callable) else raise ArgumentError, "invalid callable: #{callable}" end end |
#raw_value ⇒ Object
20 21 22 |
# File 'lib/mountapi/route/handler.rb', line 20 def raw_value @callable end |