Class: Softwear::Auth::Routing

Inherits:
Object
  • Object
show all
Defined in:
lib/softwear/auth/routing.rb

Instance Method Summary collapse

Constructor Details

#initialize(user_class, pred = nil) ⇒ Routing

Returns a new instance of Routing.



9
10
11
12
# File 'lib/softwear/auth/routing.rb', line 9

def initialize(user_class, pred = nil)
  @user_class = user_class
  @pred = pred
end

Instance Method Details

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/softwear/auth/routing.rb', line 14

def matches?(request)
  if user = @user_class.auth(request.session[:user_token])
    !@pred || @pred.call(user)
  else
    false
  end
end