Sha256: e88939d406c8d3b6d7f764510b785a937012ec3ff0136a385a6fd97ad2159864

Contents?: true

Size: 806 Bytes

Versions: 3

Compression:

Stored size: 806 Bytes

Contents

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",
    }.freeze

    class << self
      def [](code)
        new(code)
      end
    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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
open_id_authentication-2.0.2 lib/open_id_authentication/result.rb
open_id_authentication-2.0.1 lib/open_id_authentication/result.rb
open_id_authentication2-2.0.0 lib/open_id_authentication/result.rb