Class: Waw::Routing::Redirect
- Inherits:
-
RoutingRule
- Object
- RoutingRule
- Waw::Routing::Redirect
- Defined in:
- lib/waw/routing/redirect.rb
Overview
Redirect routing
Instance Method Summary collapse
-
#apply_on_browser(result, browser) ⇒ Object
Forces the browser to refresh.
- #generate_js_code(result, align = 0) ⇒ Object
-
#initialize(opts = {}) ⇒ Redirect
constructor
Creates a redirection rule instance.
Constructor Details
#initialize(opts = {}) ⇒ Redirect
Creates a redirection rule instance
7 8 9 |
# File 'lib/waw/routing/redirect.rb', line 7 def initialize(opts = {}) @opts = opts end |
Instance Method Details
#apply_on_browser(result, browser) ⇒ Object
Forces the browser to refresh
12 13 14 |
# File 'lib/waw/routing/redirect.rb', line 12 def apply_on_browser(result, browser) browser.location = @opts[:url] end |
#generate_js_code(result, align = 0) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/waw/routing/redirect.rb', line 16 def generate_js_code(result, align=0) if @opts[:url] " "*align + "window.location = \"#{@opts[:url]}\";" else " "*align + "window.location = data[1];" end end |