Class: Decidim::TermCustomizer::Admin::ImportSetTranslations
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::TermCustomizer::Admin::ImportSetTranslations
- Defined in:
- app/commands/decidim/term_customizer/admin/import_set_translations.rb
Overview
A command with all the business logic when importing translations to a set from a file submitted through the form. The file may be one of the supported import formats or a ZIP file containing a supported import file.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, translation_set) ⇒ ImportSetTranslations
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, translation_set) ⇒ ImportSetTranslations
Public: Initializes the command.
form - A form object with the params. translation_set - The translation set to which the import is
performed.
18 19 20 21 |
# File 'app/commands/decidim/term_customizer/admin/import_set_translations.rb', line 18 def initialize(form, translation_set) @form = form @translation_set = translation_set end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form wasn’t valid and we couldn’t proceed.
Returns nothing.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/commands/decidim/term_customizer/admin/import_set_translations.rb', line 29 def call return broadcast(:invalid) if form.invalid? @translations = import_translations if @translations.length.positive? broadcast(:ok, @translations) else broadcast(:invalid) end end |