Module: AreYouSure::Confirmable

Defined in:
lib/are_you_sure/confirmable.rb

Instance Method Summary collapse

Instance Method Details

#confirmed?Boolean



32
33
34
# File 'lib/are_you_sure/confirmable.rb', line 32

def confirmed?
  @are_you_sure_confirmed == 'confirmed'
end

#fill_confirmed_attributesObject



9
10
11
12
# File 'lib/are_you_sure/confirmable.rb', line 9

def fill_confirmed_attributes
  self.attributes = @are_you_sure_session[:model_attributes]
  clear_attributes_cache
end

#prepare_confirmation(confirmed, session) ⇒ Object



4
5
6
7
# File 'lib/are_you_sure/confirmable.rb', line 4

def prepare_confirmation(confirmed, session)
  @are_you_sure_confirmed = confirmed
  @are_you_sure_session = session
end

#save_if_confirmedObject



14
15
16
# File 'lib/are_you_sure/confirmable.rb', line 14

def save_if_confirmed
  confirm_with_persist { self.save }
end

#should_confirm?Boolean



36
37
38
# File 'lib/are_you_sure/confirmable.rb', line 36

def should_confirm?
  @are_you_sure_confirmed.nil?
end

#update_attribute_if_confirmed(name, value) ⇒ Object



28
29
30
# File 'lib/are_you_sure/confirmable.rb', line 28

def update_attribute_if_confirmed(name, value)
  update_attributes_if_confirmed(name => value)
end

#update_attributes_if_confirmed(attributes) ⇒ Object



23
24
25
26
# File 'lib/are_you_sure/confirmable.rb', line 23

def update_attributes_if_confirmed(attributes)
  self.attributes = attributes
  confirm_with_persist { self.update_attributes(attributes) }
end

#update_if_confirmed(attributes) ⇒ Object



18
19
20
21
# File 'lib/are_you_sure/confirmable.rb', line 18

def update_if_confirmed(attributes)
  self.attributes = attributes unless confirmed?
  confirm_with_persist { self.update(attributes) }
end