Class: PlanningClient::User

Inherits:
LogicalModel
  • Object
show all
Includes:
ServiceConfiguration
Defined in:
app/models/planning_client/user.rb

Instance Method Summary collapse

Methods included from ServiceConfiguration

included

Instance Method Details

#json_rootObject



41
42
43
# File 'app/models/planning_client/user.rb', line 41

def json_root
  'user'
end

#update_if_necessary(params) ⇒ Object

Updates User only if necessary to avoid requests with no effect.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/planning_client/user.rb', line 21

def update_if_necessary(params)
  update_needed = false 
  
  if !params[:daily_email].nil? &&
      self.daily_email_reminder_enabled != params[:daily_email]
    update_needed = true
    self.daily_email_reminder_enabled = params[:daily_email]
  end

  if !params[:email].nil? && 
      self.email != params[:email]
    update_needed = true
    self.email = params[:email]
  end

  if update_needed
    self.save
  end
end