Class: Volt::User

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

Constant Summary

Constants inherited from Model

Model::INVALID_FIELD_NAMES

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, #_id=, #add_list, #assign_attributes, #destroy, #get, #initialize, #inspect, #method_missing, #new?, #new_array_model, #new_model, #read_new_model, #remove_list, #respond_to_missing?, #set, #state_for

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, #can_create?, #can_delete?, #can_read?, #deny, #filtered_attributes, included, #owner?

Methods included from ListenerTracker

#listener_added, #listener_removed

Methods included from Modes

included

Methods included from ClassEventable

included

Methods included from 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?, #promise_for_errors, #save!, #save_to

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!

Methods included from StateHelpers

#loaded?, #loaded_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 ModelHelpers

#deep_unwrap, #event_added, #event_removed, included

Methods included from ModelWrapper

#wrap_value, #wrap_values

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

#password=(val) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'app/volt/models/user.rb', line 32

def password=(val)
  if Volt.server?
    # on the server, we bcrypt the password and store the result
    self._hashed_password = BCrypt::Password.create(val)
  else
    # Assign the attribute
    self._password = val
  end
end