Class: Owner
Overview
The model to handle this is StaffPackage
Instance Method Summary
collapse
#time_zone
#kinda_like_owner?, #owner?, #restaurant_group?, #staff?, #user?
sync_carrierwave_url
Instance Method Details
#authenticate(password) ⇒ Object
90
91
92
|
# File 'app/models/owner.rb', line 90
def authenticate(password)
valid_password? password
end
|
#restaurant_ids ⇒ Object
86
87
88
|
# File 'app/models/owner.rb', line 86
def restaurant_ids
[restaurant.id]
end
|
#to_json(options = nil) ⇒ Object
72
73
74
75
76
77
78
79
|
# File 'app/models/owner.rb', line 72
def to_json(options = nil)
data = attributes.dup
excluded_attributes = %w[encrypted_password reset_password_token reset_password_sent_at remember_created_at
sign_in_count current_sign_in_at last_sign_in_at current_sign_in_ip last_sign_in_ip created_at updated_at]
data.delete_if { |k, _v| excluded_attributes.include?(k) }
data[:manager_emails] = managers.map(&:email)
ActiveSupport::JSON.encode(data, options)
end
|
#update_staff ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'app/models/owner.rb', line 94
def update_staff
return if @skip_staff_update
return if staff.blank?
if password.present?
staff.instance_variable_set(:@skip_password_sync, true)
staff.password = password
staff. = "Password synchronized from Owner ID: #{id}"
end
if email.present?
staff.email = email
staff. = "Email synchronized from Owner ID: #{id}" unless staff.
end
staff.save
end
|