Class: Renalware::HD::ReviseHDProfile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile) ⇒ ReviseHDProfile

Returns a new instance of ReviseHDProfile.

Raises:

  • (ArgumentError)


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

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

  @profile = profile
end

Instance Attribute Details

#new_profileObject (readonly)

Returns the value of attribute new_profile.



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

def new_profile
  @new_profile
end

#profileObject (readonly)

Returns the value of attribute profile.



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

def profile
  @profile
end

Instance Method Details

#call(params) ⇒ Object



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

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

  profile.restore_attributes
  @new_profile = profile.supersede!(params)
end