Method: Devise::Models::Authenticatable#apply_to_attribute_or_variable

Defined in:
lib/devise/models/authenticatable.rb

#apply_to_attribute_or_variable(attr, method) ⇒ Object (protected)



206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/devise/models/authenticatable.rb', line 206

def apply_to_attribute_or_variable(attr, method)
  if self[attr]
    self[attr] = self[attr].try(method)

  # Use respond_to? here to avoid a regression where globally
  # configured strip_whitespace_keys or case_insensitive_keys were
  # attempting to strip or downcase when a model didn't have the
  # globally configured key.
  elsif respond_to?(attr) && respond_to?("#{attr}=")
    new_value = send(attr).try(method)
    send("#{attr}=", new_value)
  end
end