Class: KirguduCommon::User

Inherits:
KirguduBase::BaseModel
  • Object
show all
Defined in:
app/models/kirgudu_common/user.rb

Class Method Summary collapse

Instance Method Summary collapse

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(options = {})
    super(merge_options_for_json(options, {
        :methods => [:full_name],
        except: [:password]
    }))
end

#full_nameObject

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_breadcrumbsObject



88
89
90
# File 'app/models/kirgudu_common/user.rb', line 88

def name_for_breadcrumbs
    self.full_name
end

#status_nameObject



84
85
86
# File 'app/models/kirgudu_common/user.rb', line 84

def status_name
    #
end

#to_sObject



92
93
94
# File 'app/models/kirgudu_common/user.rb', line 92

def to_s
    self.full_name
end