Class: Groundskeeper::Middleware
- Inherits:
-
Object
- Object
- Groundskeeper::Middleware
- Defined in:
- lib/groundskeeper/middleware.rb,
lib/groundskeeper/middleware/path.rb,
lib/groundskeeper/middleware/header.rb,
lib/groundskeeper/middleware/parameter.rb,
lib/groundskeeper/middleware/subdomain.rb
Defined Under Namespace
Classes: Header, Parameter, Path, Subdomain
Constant Summary collapse
- NAMESPACE_KEY =
"Groundskeeper-Namespace"
- TENANT_KEY =
"Groundskeeper-Tenant"
- MODEL_KEY =
:model
- QUERY_KEY =
:query
- DEFAULT_KEY =
:default
- QUERY_DEFAULT =
->(model, slug) do model.find_by_slug(slug) end
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
12 13 14 15 16 17 18 |
# File 'lib/groundskeeper/middleware.rb', line 12 def initialize(app, = {}) raise ArgumentError, "missing model" unless .key?(model_key) @options = @app = app @env = {} end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/groundskeeper/middleware.rb', line 20 def call(env) @env = env env[namespace_key] = namespace env[tenant_key] = tenant @app.call(env) end |