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.

Direct Known Subclasses

RackAdapter, RailsAdapter, SinatraAdapter::Adapter, TestCase::MockController, TestCase::RailsRequestAdapter

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (AbstractAdapter) initialize(controller)



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

- (Object) method_missing(id, *args, &block) (private)



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

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

Instance Attribute Details

- (Object) controller

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

- (Object) authenticate_with_http_basic(&block)



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

- (Object) cookies



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

def cookies
  controller.cookies
end

- (Boolean) last_request_update_allowed?



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

- (Object) params



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

def params
  controller.params
end

- (Object) request



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

def request
  controller.request
end

- (Object) request_content_type



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

def request_content_type
  request.content_type
end

- (Boolean) responds_to_last_request_update_allowed?



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

- (Boolean) responds_to_single_access_allowed?



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

- (Object) session



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

def session
  controller.session
end

- (Boolean) single_access_allowed?



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

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