Class: MiddleSquid::Adapter Abstract
- Inherits:
-
Object
- Object
- MiddleSquid::Adapter
- Defined in:
- lib/middle_squid/adapter.rb
Overview
Direct Known Subclasses
Instance Attribute Summary collapse
-
#handler ⇒ #call
Returns whatever was passed to Builder#run.
Instance Method Summary collapse
-
#handle(url, extras = []) ⇒ Object
Execute the user handler (see #handler) and calls
#output
. -
#initialize(options = {}) ⇒ Adapter
constructor
Returns a new instance of Adapter.
-
#output(action, options) ⇒ Object
Pass an action to an underlying software.
Constructor Details
#initialize(options = {}) ⇒ Adapter
Returns a new instance of Adapter. Use Builder#use instead.
14 15 16 |
# File 'lib/middle_squid/adapter.rb', line 14 def initialize( = {}) @options = end |
Instance Attribute Details
#handler ⇒ #call
Returns whatever was passed to Builder#run.
10 11 12 |
# File 'lib/middle_squid/adapter.rb', line 10 def handler @handler end |
Instance Method Details
#handle(url, extras = []) ⇒ Object
Execute the user handler (see #handler) and calls #output
.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/middle_squid/adapter.rb', line 22 def handle(url, extras = []) uri = MiddleSquid::URI.parse url raise InvalidURIError, "invalid URL received: '#{url}'" if !uri || !uri.host action, = catch :action do @handler.call uri, extras throw :action, [:accept, {}] end output action, end |
#output(action, options) ⇒ Object
Pass an action to an underlying software.
- accept
-
(no options)
- redirect
-
Options:
-
status
[Fixnum
] -
url
[String
]
-
- replace
-
Options:
-
url
[String
]
-
50 51 52 |
# File 'lib/middle_squid/adapter.rb', line 50 def output(action, ) raise NotImplementedError end |