Sha256: f5d3154b278a7f4a95cc7542c002e05bb29ee9e90df9bc1939001bc2e80f659b

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'active_record'
require 'authlogic'
require 'oauth'
require 'oauth2'

this = File.dirname(__FILE__)
library = "#{this}/authlogic_connect"

module AuthlogicConnect
  KEY = "connect"
  
  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

require "#{library}/callback_filter"
require "#{library}/token"
require "#{library}/openid"
require "#{library}/oauth"
require "#{library}/common"

custom_models = ["#{library}/token"]
custom_models += Dir["#{library}/oauth/tokens"]
custom_models +=Dir["#{library}/openid/tokens"]

custom_models.each do |path|
  $LOAD_PATH << path
  ActiveSupport::Dependencies.load_paths << path
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authlogic-connect-0.0.3.3 lib/authlogic-connect.rb