Sha256: 68797b4ff4f6af5e92f6abd049cc78b17b13c11e09744a7f5eecf439dd865175

Contents?: true

Size: 997 Bytes

Versions: 27

Compression:

Stored size: 997 Bytes

Contents

module AuthlogicConnect
  KEY = "connect" unless defined?(KEY)
  OAUTH = "oauth" unless defined?(OAUTH)
  OPEN_ID = "open_id" unless defined?(OPEN_ID)
  
  class << self
    
    attr_accessor :config
    
    def config=(value)
      value.recursively_symbolize_keys!
      @config = value
    end
    
    def key(path)
      result = self.config
      path.to_s.split(".").each { |node| result = result[node.to_sym] if result }
      result
    end
    
    def credentials(service)
      key("#{KEY}.#{service.to_s}")
    end
    
    def services
      key(KEY)
    end
    
    def service_names
      services.keys.collect(&:to_s)
    end
    
    def include?(service)
      !credentials(service).nil?
    end
    
    def token(key)
      raise "can't find key '#{key.to_s}' in AuthlogicConnect.config" unless AuthlogicConnect.include?(key) and !key.to_s.empty?
      "#{key.to_s.camelcase}Token".constantize
    end
    
    def consumer(key)
      token(key).consumer
    end
  end
end

Version data entries

27 entries across 27 versions & 8 rubygems

Version Path
robdimarco-authlogic-connect-0.0.6 lib/authlogic_connect/authlogic_connect.rb
anideo-authlogic-connect-0.0.6 lib/authlogic_connect/authlogic_connect.rb
jspooner-authlogic-connect-0.0.20 lib/authlogic_connect/authlogic_connect.rb
jspooner-authlogic-connect-0.0.19 lib/authlogic_connect/authlogic_connect.rb
foreverman-authlogic-connect-0.0.4 lib/authlogic_connect/authlogic_connect.rb
foreverman-authlogic-connect-0.0.3 lib/authlogic_connect/authlogic_connect.rb
foreverman-authlogic-connect-0.0.2 lib/authlogic_connect/authlogic_connect.rb
foreverman-authlogic-connect-0.0.1 lib/authlogic_connect/authlogic_connect.rb
foreverman-authlogic-connect-0.0.6 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-andrewacove-0.5.7 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-0.0.6 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-0.0.5.1 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-0.0.5 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-andrewacove-0.5.6 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-andrewacove-0.5.5 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-andrewacove-0.5.4 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-andrewacove-0.5.2 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-andrewacove-0.5.0 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-0.0.4.06 lib/authlogic_connect/authlogic_connect.rb
authlogic-connect-x-0.0.4.05x lib/authlogic_connect/authlogic_connect.rb