Sha256: 1bb0f235763c9d756a4341f54ad5ed98fbd95195f9301cb18fba513177aaf213

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require "devise"

module Identity
  module Mixins
    autoload :User, 'identity/mixins/user'
  end

  mattr_accessor :devise_modules do
    [
      :database_authenticatable,
      :registerable,
      :recoverable,
      :rememberable,
      :trackable,
      :validatable
    ]
  end

  mattr_accessor(:user_class_name) { "::User" }
  mattr_accessor(:layout) { 'application' }
  mattr_accessor(:auth_routes) { {} }
  mattr_accessor(:active_scope) { :all }

  def self.user_class
    user_class_name.constantize
  end

  def self.controllers
    if Devise.omniauth_providers.any?
      { omniauth_callbacks: "identity/omniauth_callbacks" }
    else
      {  }
    end
  end

  def self.setup
    yield self
  end

  def self.method_missing(name, *args, &block)
    if delegate_to_devise?(name.to_s)
      Devise.public_send(name, *args, &block)
    else
      super
    end
  end

  def self.delegate_to_devise?(name)
    name.in?(%w(omniauth)) ||
    name.ends_with?('=') && Devise.respond_to?(name)
  end

  def self.respond_to_missing?(name, include_private = false)
    (name.to_s.ends_with?('=') && Devise.respond_to?(name, include_private)) || super
  end

end

require "identity/engine"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
anadea-identity-0.5.4 lib/identity.rb
anadea-identity-0.5.3 lib/identity.rb