Class: Lcms::Engine::MaterialForm
- Inherits:
-
Object
- Object
- Lcms::Engine::MaterialForm
- Includes:
- ActiveModel::Model, GoogleCredentials
- Defined in:
- app/forms/lcms/engine/material_form.rb
Instance Attribute Summary collapse
-
#material ⇒ Object
Returns the value of attribute material.
-
#service_errors ⇒ Object
Returns the value of attribute service_errors.
Instance Method Summary collapse
-
#initialize(attributes = {}, opts = {}) ⇒ MaterialForm
constructor
A new instance of MaterialForm.
- #save ⇒ Object
Constructor Details
#initialize(attributes = {}, opts = {}) ⇒ MaterialForm
Returns a new instance of MaterialForm.
16 17 18 19 |
# File 'app/forms/lcms/engine/material_form.rb', line 16 def initialize(attributes = {}, opts = {}) super(attributes) @options = opts end |
Instance Attribute Details
#material ⇒ Object
Returns the value of attribute material.
14 15 16 |
# File 'app/forms/lcms/engine/material_form.rb', line 14 def material @material end |
#service_errors ⇒ Object
Returns the value of attribute service_errors.
14 15 16 |
# File 'app/forms/lcms/engine/material_form.rb', line 14 def service_errors @service_errors end |
Instance Method Details
#save ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/forms/lcms/engine/material_form.rb', line 21 def save return false unless valid? params = { dpi: [:dpi], import_retry: [:import_retry], source_type: source_type.presence }.compact service = MaterialBuildService.new google_credentials, params @material = service.build link @service_errors = service.errors material.update preview_links: {} after_reimport_hook true rescue StandardError => e Rails.logger.error "#{e.}\n #{e.backtrace.join("\n ")}" errors.add(:link, e.) false end |