Class: Authlogic::ControllerAdapters::AbstractAdapter

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ AbstractAdapter

Returns a new instance of AbstractAdapter.



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

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)



63
64
65
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 63

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

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



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

def controller
  @controller
end

Instance Method Details

#authenticate_with_http_basic(&block) ⇒ Object



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

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)


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

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

#cookiesObject



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

def cookies
  controller.cookies
end

#last_request_update_allowed?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 57

def last_request_update_allowed?
  controller.send(:last_request_update_allowed?)
end

#paramsObject



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

def params
  controller.params
end

#requestObject



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

def request
  controller.request
end

#request_content_typeObject



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

def request_content_type
  request.content_type
end

#responds_to_last_request_update_allowed?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 53

def responds_to_last_request_update_allowed?
  controller.respond_to?(:last_request_update_allowed?, true)
end

#responds_to_single_access_allowed?Boolean

Returns:

  • (Boolean)


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

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

#sessionObject



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

def session
  controller.session
end

#single_access_allowed?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 49

def single_access_allowed?
  controller.send(:single_access_allowed?)
end