Sha256: 8cb41a2a3458374655605422c33de971f24f93fa783dd301fe791290e6b70e86

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module Passport
  module Installation
    def self.included(base)
      base.extend ClassMethods
    end
    
    module ClassMethods
      attr_accessor :installed
      
      def install
        return if installed
        
        require "#{root}/lib/passport/support/#{adapter}"
        require "#{root}/lib/passport/oauth"
        
        if defined?(Rails)          
          custom_models = ["#{root}/lib/passport/support/#{adapter}"] + Dir["#{root}/lib/passport/oauth/tokens"]
          #custom_models +=  Dir["#{library}/openid/tokens"]
          
          # Rails 3/2 config
          load_path_method = ActiveSupport::Dependencies.respond_to?(:autoload_paths) ? :autoload_paths : :load_paths
          
          custom_models.each do |path|
            $LOAD_PATH << path
            ActiveSupport::Dependencies.send(load_path_method) << path
          end
        end
        
        if defined?(ActionController::Base)
          ActionController::Base.helper(Passport::Oauth::ViewHelper)
        end
        if defined?(ActionView::Helpers::FormBuilder)
          ActionView::Helpers::FormBuilder.send(:include, Passport::Oauth::ViewHelper)
        end
        
        installed = true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
passport-0.1.1 lib/passport/core/installation.rb