Class: OpenIdAuthentication::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/open_id_authentication/result.rb

Constant Summary collapse

ERROR_MESSAGES =
{
  missing: "Sorry, the OpenID server couldn't be found",
  invalid: "Sorry, but this does not appear to be a valid OpenID",
  canceled: "OpenID verification was canceled",
  failed: "OpenID verification failed",
  setup_needed: "OpenID verification needs setup",
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ Result

Returns a new instance of Result.



17
18
19
# File 'lib/open_id_authentication/result.rb', line 17

def initialize(code)
  @code = code
end

Class Method Details

.[](code) ⇒ Object



12
13
14
# File 'lib/open_id_authentication/result.rb', line 12

def [](code)
  new(code)
end

Instance Method Details

#messageObject



35
36
37
# File 'lib/open_id_authentication/result.rb', line 35

def message
  ERROR_MESSAGES[@code]
end

#statusObject



21
22
23
# File 'lib/open_id_authentication/result.rb', line 21

def status
  @code
end

#successful?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/open_id_authentication/result.rb', line 27

def successful?
  @code == :successful
end

#unsuccessful?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/open_id_authentication/result.rb', line 31

def unsuccessful?
  ERROR_MESSAGES.keys.include?(@code)
end