Sha256: d31242438a24d2c49fc70f778a6fda5996127b7dea803c35b3f5cc752aedeb09

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'google_authentication/acts_as_google_user'

# Main module for the gem
module GoogleAuthentication

  # domain configuration
  mattr_accessor :domain
  # default value for google domain used for authentication
  @@domain = "gmail.com"

  # model name configuration
  mattr_accessor :model_name
  # default model used (singular name)
  @@model_name = :user

  # Allows config in initializer
  # @yield [self] Allows config in initializer using the same syntax as Devise
  # @yieldparam [GoogleAuthentication] config the module itself
  # @example Changing the authentication setup
  #   GoogleAuthentication.setup do |config|
  #     config.domain = 'your-google-apps-domain.com'
  #     config.model_name = :account
  #   end
  def self.setup
    yield self
  end

  # Used in the routes file to decide wheter to add routes
  # to the application
  # @return [bool] true iff the GoogleAuthentication model is already defined
  def self.define_routes?
    Object.const_defined?(model_name.to_s.camelize)
  end

  # Return a symbol which is used to build devise routes
  # @return [Symbol] a symbol representing the table name used by devise
  def self.devise_table
    model_name.to_s.pluralize.to_sym
  end

  # require the engine if rails is defined
  require 'google_authentication/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
google_authentication-0.1.0 lib/google_authentication.rb