Module: RhodeIsland::ActiveRecordExtensions::InstanceMethods

Defined in:
lib/rhode_island/active_record_extensions.rb

Instance Method Summary collapse

Instance Method Details

#make(new_state) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/rhode_island/active_record_extensions.rb', line 30

def make(new_state)
  old_state = self.state
  before_leaving_method_name = :"before_leaving_#{old_state}"
  before_entering_method_name = :"before_making_#{new_state}"
  self.send(before_leaving_method_name) if self.respond_to?(before_leaving_method_name)
  self.send(before_entering_method_name) if self.respond_to?(before_entering_method_name)
  self.state = new_state
  new_state
end

#make!(new_state) ⇒ Object



40
41
42
43
# File 'lib/rhode_island/active_record_extensions.rb', line 40

def make!(new_state)
  self.make(new_state)
  self.save!
end