Sha256: d3bcfc00952e3d1fb60dce21b880e1c04d4cbd3fc5f22d3f0e9512be2acabc33

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 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"
    }

    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
open_id_authentication-1.3.0 lib/open_id_authentication/result.rb
open_id_authentication-1.2.0 lib/open_id_authentication/result.rb