Sha256: 7972a9fa2537e0b4cb93332169969a94429384a276ed9ecce6b27c8105746be3
Contents?: true
Size: 519 Bytes
Versions: 2
Compression:
Stored size: 519 Bytes
Contents
class Saasable::Middleware def initialize app @app = app end def call env # Loads all models so we know how to apply the scopes on Rails Rails::Mongoid.load_models(Rails.application) if defined?(Rails::Mongoid) env[:saasable] = {:current_saas => saas_for_host(env["SERVER_NAME"])} env[:saasable][:current_saas].activate! @app.call env end private def saas_for_host hostname Saasable::Mongoid::SaasDocument.saas_document.find_by_host!(hostname) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
saasable-0.2.2 | lib/saasable/middleware.rb |
saasable-0.2.0 | lib/saasable/middleware.rb |