Class: Renalware::HD::ReviseHDProfile

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/hd/revise_hd_profile.rb

Instance Method Summary collapse

Constructor Details

#initialize(profile) ⇒ ReviseHDProfile

Returns a new instance of ReviseHDProfile.

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'app/models/renalware/hd/revise_hd_profile.rb', line 6

def initialize(profile)
  raise(ArgumentError, "Cannot revise a new Profile") unless profile.persisted?

  @profile = profile
end

Instance Method Details

#call(params) ⇒ Object



12
13
14
15
16
17
18
19
# File 'app/models/renalware/hd/revise_hd_profile.rb', line 12

def call(params)
  profile.assign_attributes(params)
  return true unless profile.changed?
  return false unless profile.valid?

  profile.restore_attributes
  profile.supersede!(params)
end