Module: Revise::Models::Authenticatable::ClassMethods
- Defined in:
- lib/revise/models/authenticatable.rb
Instance Method Summary collapse
- #find_first_by_auth_conditions(conditions) ⇒ Object
- #find_for_authentication(conditions) ⇒ Object
-
#find_or_initialize_with_error_by(attribute, value, error = :invalid) ⇒ Object
:nodoc:.
-
#find_or_initialize_with_errors(required_attributes, attributes, error = :invalid) ⇒ Object
Find an initialize a group of attributes based on a list of required attributes.
Instance Method Details
#find_first_by_auth_conditions(conditions) ⇒ Object
93 94 95 |
# File 'lib/revise/models/authenticatable.rb', line 93 def find_first_by_auth_conditions(conditions) to_adapter.find_first revise_param_filter.filter(conditions) end |
#find_for_authentication(conditions) ⇒ Object
89 90 91 |
# File 'lib/revise/models/authenticatable.rb', line 89 def find_for_authentication(conditions) find_first_by_auth_conditions(conditions) end |
#find_or_initialize_with_error_by(attribute, value, error = :invalid) ⇒ Object
:nodoc:
97 98 99 |
# File 'lib/revise/models/authenticatable.rb', line 97 def find_or_initialize_with_error_by(attribute, value, error=:invalid) #:nodoc: find_or_initialize_with_errors([attribute], { attribute => value }, error) end |
#find_or_initialize_with_errors(required_attributes, attributes, error = :invalid) ⇒ Object
Find an initialize a group of attributes based on a list of required attributes.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/revise/models/authenticatable.rb', line 102 def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc: attributes = attributes.slice(*required_attributes) attributes.delete_if { |key, value| value.blank? } if attributes.size == required_attributes.size record = find_first_by_auth_conditions(attributes) end unless record record = new required_attributes.each do |key| value = attributes[key] record.send("#{key}=", value) record.errors.add(key, value.present? ? error : :blank) end end record end |