-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compatibility issue with rails >3.0 wanting the model_name class …
…method
- Loading branch information
1 parent
f2f6988
commit faa063f
Showing
5 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Authlogic bridge for Sinatra | ||
module Authlogic | ||
module ControllerAdapters | ||
module SinatraAdapter | ||
class Cookies | ||
attr_reader :request, :response | ||
|
||
def initialize(request, response) | ||
@request = request | ||
@response = response | ||
end | ||
|
||
def delete(key, options = {}) | ||
@request.cookies.delete(key) | ||
end | ||
|
||
def []=(key, options) | ||
@response.set_cookie(key, options) | ||
end | ||
|
||
def method_missing(meth, *args, &block) | ||
@request.cookies.send(meth, *args, &block) | ||
end | ||
end | ||
|
||
class Controller | ||
attr_reader :request, :response, :cookies | ||
|
||
def initialize(request, response) | ||
@request = request | ||
@cookies = Cookies.new(request, response) | ||
end | ||
|
||
def session | ||
env['rack.session'] | ||
end | ||
|
||
def method_missing(meth, *args, &block) | ||
@request.send meth, *args, &block | ||
end | ||
end | ||
|
||
class Adapter < AbstractAdapter | ||
def cookie_domain | ||
env['SERVER_NAME'] | ||
end | ||
|
||
module Implementation | ||
def self.included(klass) | ||
klass.send :before do | ||
controller = Controller.new(request, response) | ||
Authlogic::Session::Base.controller = Adapter.new(controller) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
Sinatra::Request.send(:include, Authlogic::ControllerAdapters::SinatraAdapter::Adapter::Implementation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters