7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/sq_auth/sq_auth_integration/sq_auth_rack.rb', line 7
def self.alter_environment options={}
if defined?(Rails)
if (Rails.application.nil?)
options[:engine].instance_eval do
initializer "Rails::Engine.add_sq_auth" do |app|
app.middleware.use SqAuth::SqAuthIntegration::SqAuthRack::Middleware
end
end
else
Rails.application.class.instance_eval do
config.middleware.use SqAuth::SqAuthIntegration::SqAuthRack::Middleware
end
end
elsif defined?(Sinatra)
if options[:klass].respond_to?(:use)
sinatra_class = options[:klass]
else
sinatra_class = Sinatra::Base
end
sinatra_class.use Rack::Session::Cookie, :expire_after => 2592000
sinatra_class.use SqAuth::SqAuthIntegration::SqAuthRack::Middleware
end
end
|