Class: Authentication::Logic::ActsAsAuthentic::Queries::CaseSensitivity Private

Inherits:
Object
  • Object
show all
Defined in:
lib/auth/logic/acts_as_authentic/queries/case_sensitivity.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

E_UNABLE_TO_DETERMINE_SENSITIVITY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

<<~EOS
  Authentication::Logic was unable to determine what case-sensitivity to use when
  searching for email/login. To specify a sensitivity, validate the
  uniqueness of the email/login and use the `case_sensitive` option,
  like this:

      validates :email, uniqueness: { case_sensitive: false }

  Authentication::Logic will now perform a case-insensitive query.
EOS

Instance Method Summary collapse

Constructor Details

#initialize(model_class, attribute) ⇒ CaseSensitivity

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CaseSensitivity.



21
22
23
24
# File 'lib/auth/logic/acts_as_authentic/queries/case_sensitivity.rb', line 21

def initialize(model_class, attribute)
  @model_class = model_class
  @attribute = attribute.to_sym
end

Instance Method Details

#sensitive?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


27
28
29
30
31
32
33
34
35
# File 'lib/auth/logic/acts_as_authentic/queries/case_sensitivity.rb', line 27

def sensitive?
  sensitive = uniqueness_validator_options[:case_sensitive]
  if sensitive.nil?
    ::Kernel.warn(E_UNABLE_TO_DETERMINE_SENSITIVITY)
    false
  else
    sensitive
  end
end