Sha256: feb91fcf426df2cb12e2e08af86775fdb1723a1dc87390fab186ef70560bbcb4

Contents?: true

Size: 469 Bytes

Versions: 2

Compression:

Stored size: 469 Bytes

Contents

module PansophyAuthenticator
  class Matcher
    def initialize(keys, application)
      @keys        = keys
      @application = application
    end

    def validate!(given_key)
      fail Error, "Invalid key for #{@application}" unless valid?(given_key)
    end

    def valid?(given_key)
      given_key == key
    end

    def key
      fail Error, "#{@application} is not defined" unless @keys.key?(@application)
      @keys.fetch(@application)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pansophy_authenticator-0.2.0 lib/pansophy_authenticator/matcher.rb
pansophy_authenticator-0.1.0 lib/pansophy_authenticator/matcher.rb