Class: Lcms::Engine::DocumentForm

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, GoogleCredentials
Defined in:
app/forms/lcms/engine/document_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, opts = {}) ⇒ DocumentForm

Returns a new instance of DocumentForm.



18
19
20
21
22
# File 'app/forms/lcms/engine/document_form.rb', line 18

def initialize(attributes = {}, opts = {})
  @is_reimport = attributes.delete(:reimport).present? || false
  super(attributes)
  @options = opts
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



16
17
18
# File 'app/forms/lcms/engine/document_form.rb', line 16

def document
  @document
end

#service_errorsObject (readonly)

Returns the value of attribute service_errors.



16
17
18
# File 'app/forms/lcms/engine/document_form.rb', line 16

def service_errors
  @service_errors
end

Instance Method Details

#saveObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/forms/lcms/engine/document_form.rb', line 24

def save
  return false unless valid?

  @document = build_document
  after_reimport_hook
  @document.update(reimported: true)
rescue StandardError => e
  @document&.update(reimported: false)
  Rails.logger.error "#{e.message}\n #{e.backtrace.join("\n ")}"
  errors.add(:link, e.message)
  false
end