Class: SubscribeForm

Inherits:
ApplicationForm show all
Defined in:
app/forms/subscribe_form.rb

Instance Attribute Summary

Attributes inherited from ApplicationForm

#raw_responce

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationForm

#persisted?

Class Method Details

.confirm!(token) ⇒ Object



18
19
20
# File 'app/forms/subscribe_form.rb', line 18

def confirm!(token)
  TranslationCms::Api::Subscriber.update(id: token) if token.present?
end

.unsubscribe!(token) ⇒ Object



22
23
24
# File 'app/forms/subscribe_form.rb', line 22

def unsubscribe!(token)
  TranslationCms::Api::Subscriber.destroy(id: token) if token.present?
end

Instance Method Details

#submitObject



9
10
11
12
13
14
15
# File 'app/forms/subscribe_form.rb', line 9

def submit
  return false unless valid?

  api_answer = TranslationCms::Api::Subscriber.create(attributes)
  merge_responce! api_answer
  errors.empty?
end