module OpenIdAuthentication class Result 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" } def self.[](code) new(code) end def initialize(code) @code = code end def status @code end ERROR_MESSAGES.keys.each { |state| define_method("#{state}?") { @code == state } } def successful? @code == :successful end def unsuccessful? ERROR_MESSAGES.keys.include?(@code) end def message ERROR_MESSAGES[@code] end end end