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