Class: MiniAuth::ApiGuard

Inherits:
Guard
  • Object
show all
Defined in:
lib/mini_auth/api_guard.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Guard

#auth_url, #guest?, #logged_in?

Constructor Details

#initialize(name, model, request) ⇒ ApiGuard

Returns a new instance of ApiGuard.

Parameters:

  • name (Symbol)
  • model (Class)
  • request (ActionDispatch::Request)


11
12
13
14
15
# File 'lib/mini_auth/api_guard.rb', line 11

def initialize(name, model, request)
  @name = name
  @model = model
  @request = request
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/mini_auth/api_guard.rb', line 6

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/mini_auth/api_guard.rb', line 6

def name
  @name
end

#requestObject (readonly)

Returns the value of attribute request.



6
7
8
# File 'lib/mini_auth/api_guard.rb', line 6

def request
  @request
end

Instance Method Details

#attempt!(credentials, remember = nil) ⇒ Object

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/mini_auth/api_guard.rb', line 17

def attempt!(credentials, remember = nil)
  raise NotImplementedError, 'ApiGuard does not support auth attempt.'
end

#login!(user, remember = nil) ⇒ Object



21
22
23
# File 'lib/mini_auth/api_guard.rb', line 21

def login!(user, remember = nil)
  @user = user
end

#logout!Object



25
26
27
# File 'lib/mini_auth/api_guard.rb', line 25

def logout!
  @user = nil
end

#userObject



29
30
31
# File 'lib/mini_auth/api_guard.rb', line 29

def user
  @user ||= infer_current_user
end