Class: Volt::User

Inherits:
Model show all
Defined in:
app/volt/models/user.rb

Constant Summary

Constants inherited from Model

Model::INVALID_FIELD_NAMES

Constants included from FieldHelpers

FieldHelpers::FIELD_CASTS, FieldHelpers::NUMERIC_CAST

Constants included from Models::Helpers::Base

Models::Helpers::Base::ID_CHARS

Instance Attribute Summary

Attributes inherited from Model

#attributes, #options, #parent, #path, #persistor

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#!, #==, #_id, #assign_attributes, #destroy, #get, #id, #id=, #initialize, #inspect, #method_missing, #new?, #new_array_model, #new_model, #read_new_model, #release, #respond_to_missing?, #retain, #set, #state_for, #to_json, #update

Methods included from Models::Helpers::ChangeHelpers

included, #run_changed

Methods included from ReactiveAccessors

#__reactive_dependency_get, included

Methods included from Associations

included

Methods included from Model::Permissions

#action_allowed?, #allow, #allow_and_deny_fields, #deny, #filtered_attributes, included, #owner?

Methods included from Models::Helpers::ListenerTracker

#listener_added, #listener_removed

Methods included from Modes

included

Methods included from ClassEventable

included

Methods included from Models::Helpers::Dirty

#attribute_will_change!, #changed?, #changed_attributes, #changes, #clear_tracked_changes!, #method_missing, #revert_changes!, #was

Methods included from FieldHelpers

included

Methods included from Buffer

#buffer, #buffer?, included, #promise_for_errors, #save!, #save_to, #save_to=, #saved?, #saved_state

Methods included from Validations

#clear_server_errors, #error_in_changed_attributes?, #errors, included, #mark_all_fields!, #mark_field!, #marked_errors, #marked_fields, #server_errors, #validate, #validate!

Methods included from Models::Helpers::Model

#saved?, #saved_state

Methods included from StateManager

#change_state_to, #state_for

Methods included from ModelHashBehaviour

#clear, #delete, #each, #each_pair, #each_with_object, #empty?, #key?, #keys, #nil?, #size, #to_h

Methods included from Models::Helpers::Base

#deep_unwrap, #event_added, #event_removed, #generate_id, included, #root, #self_attributes, #setup_persistor, #store

Methods included from ModelWrapper

#wrap_value, #wrap_values

Methods included from LifecycleCallbacks

included, #run_callbacks, #stop_chain

Constructor Details

This class inherits a constructor from Volt::Model

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Volt::Model

Class Method Details

.login_fieldObject

returns login field name depending on config settings



8
9
10
11
12
13
14
# File 'app/volt/models/user.rb', line 8

def self.
  if Volt.config.try(:public).try(:auth).try(:use_username)
    :username
  else
    :email
  end
end

Instance Method Details

#hash_passwordObject



42
43
44
45
46
47
48
49
50
51
52
# File 'app/volt/models/user.rb', line 42

def hash_password
  password = get('password')

  if password.present?
    # Clear the password
    set('password', nil)

    # Set the hashed_password field instead
    set('hashed_password', BCrypt::Password.create(password))
  end
end