Class: KirguduCommon::User
- Inherits:
-
KirguduBase::BaseModel
- Object
- KirguduBase::BaseModel
- KirguduCommon::User
- Defined in:
- app/models/kirgudu_common/user.rb
Class Method Summary collapse
- .apply_filters_to_query(query, filters = {}) ⇒ Object
-
.get_by_email(email) ⇒ Object
DATABASE METHODS #################################.
- .get_by_email_or_phone(username) ⇒ Object
- .get_by_phone(phone) ⇒ Object
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#full_name ⇒ Object
METHODS #################################.
- #name_for_breadcrumbs ⇒ Object
- #status_name ⇒ Object
- #to_s ⇒ Object
Class Method Details
.apply_filters_to_query(query, filters = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/kirgudu_common/user.rb', line 40 def self.apply_filters_to_query(query, filters={}) filters ||= {} filters.merge!({ order: { last_name: :asc, first_name: :asc } }) super(query, filters) end |
.get_by_email(email) ⇒ Object
DATABASE METHODS #################################
58 59 60 |
# File 'app/models/kirgudu_common/user.rb', line 58 def self.get_by_email(email) self.where(email: email.to_s.strip).first if email end |
.get_by_email_or_phone(username) ⇒ Object
66 67 68 69 70 71 |
# File 'app/models/kirgudu_common/user.rb', line 66 def self.get_by_email_or_phone(username) if username username = username.to_s.strip self.where { (phone == username) | (email == username) }.first end end |
.get_by_phone(phone) ⇒ Object
62 63 64 |
# File 'app/models/kirgudu_common/user.rb', line 62 def self.get_by_phone(phone) self.where(phone: phone.to_s.strip).first if phone end |
Instance Method Details
#as_json(options = {}) ⇒ Object
97 98 99 100 101 102 |
# File 'app/models/kirgudu_common/user.rb', line 97 def as_json( = {}) super((, { :methods => [:full_name], except: [:password] })) end |
#full_name ⇒ Object
METHODS #################################
76 77 78 79 80 81 82 |
# File 'app/models/kirgudu_common/user.rb', line 76 def full_name nm = self.first_name if self.last_name nm = "#{self.last_name} #{nm}" end nm end |
#name_for_breadcrumbs ⇒ Object
88 89 90 |
# File 'app/models/kirgudu_common/user.rb', line 88 def self.full_name end |
#status_name ⇒ Object
84 85 86 |
# File 'app/models/kirgudu_common/user.rb', line 84 def status_name # end |
#to_s ⇒ Object
92 93 94 |
# File 'app/models/kirgudu_common/user.rb', line 92 def to_s self.full_name end |