Class: Floodgate::Control
- Inherits:
-
Object
- Object
- Floodgate::Control
- Defined in:
- lib/floodgate/control.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #filter_traffic?(env) ⇒ Boolean
-
#initialize(app, app_id, api_token) ⇒ Control
constructor
A new instance of Control.
- #redirect? ⇒ Boolean
- #redirect_url ⇒ Object
Constructor Details
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
3 4 5 |
# File 'lib/floodgate/control.rb', line 3 def app @app end |
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/floodgate/control.rb', line 3 def config @config end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/floodgate/control.rb', line 13 def call(env) return app.call(env) unless filter_traffic?(env) if redirect? [307, { 'Location' => redirect_url }, []] else [503, {}, ['Application Unavailable']] end end |
#filter_traffic?(env) ⇒ Boolean
23 24 25 |
# File 'lib/floodgate/control.rb', line 23 def filter_traffic?(env) config.filter_traffic?(env) end |
#redirect? ⇒ Boolean
27 28 29 |
# File 'lib/floodgate/control.rb', line 27 def redirect? config.redirect? end |
#redirect_url ⇒ Object
31 32 33 |
# File 'lib/floodgate/control.rb', line 31 def redirect_url config.redirect_url end |