Class: Authlogic::ControllerAdapters::AbstractAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/authlogic/controller_adapters/abstract_adapter.rb

Overview

Abstract Adapter

Allows you to use Authlogic in any framework you want, not just rails. See the RailsAdapter or MerbAdapter for an example of how to adapt Authlogic to work with your framework.

Direct Known Subclasses

MerbAdapter, RailsAdapter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ AbstractAdapter

Returns a new instance of AbstractAdapter


9
10
11
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 9

def initialize(controller)
  self.controller = controller
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args, &block) ⇒ Object (private)


51
52
53
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 51

def method_missing(id, *args, &block)
  controller.send(id, *args, &block)
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller


7
8
9
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 7

def controller
  @controller
end

Instance Method Details

#authenticate_with_http_basic(&block) ⇒ Object


13
14
15
16
17
18
19
20
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 13

def authenticate_with_http_basic(&block)
  @auth = Rack::Auth::Basic::Request.new(controller.request.env)
  if @auth.provided? and @auth.basic?
    block.call(*@auth.credentials)
  else
    false
  end
end

Raises:

  • (NotImplementedError)

26
27
28
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 26

def cookie_domain
  raise NotImplementedError.new("The cookie_domain method has not been implemented by the controller adapter")
end

#cookiesObject


22
23
24
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 22

def cookies
  controller.cookies
end

#paramsObject


30
31
32
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 30

def params
  controller.params
end

#requestObject


34
35
36
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 34

def request
  controller.request
end

#request_content_typeObject


38
39
40
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 38

def request_content_type
  request.content_type
end

#sessionObject


42
43
44
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 42

def session
  controller.session
end

#single_access_allowed?Boolean

Returns:

  • (Boolean)

46
47
48
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 46

def single_access_allowed?
  controller.respond_to?(:single_access_allowed?, true) && controller.send(:single_access_allowed?)
end