Class: OpenIdAuthentication::Result

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

Constant Summary collapse

ERROR_MESSAGES =
{
  :missing      => "Sorry, the OpenID server couldn't be found",
  :canceled     => "OpenID verification was canceled",
  :failed       => "OpenID verification failed",
  :setup_needed => "OpenID verification needs setup"
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ Result

Returns a new instance of Result.



39
40
41
# File 'lib/open_id_authentication/lib/open_id_authentication.rb', line 39

def initialize(code)
  @code = code
end

Class Method Details

.[](code) ⇒ Object



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

def self.[](code)
  new(code)
end

Instance Method Details

#===(code) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/open_id_authentication/lib/open_id_authentication.rb', line 43

def ===(code)
  if code == :unsuccessful && unsuccessful?
    true
  else
    @code == code
  end
end

#messageObject



61
62
63
# File 'lib/open_id_authentication/lib/open_id_authentication.rb', line 61

def message
  ERROR_MESSAGES[@code]
end

#successful?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/open_id_authentication/lib/open_id_authentication.rb', line 53

def successful?
  @code == :successful
end

#unsuccessful?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/open_id_authentication/lib/open_id_authentication.rb', line 57

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