Sha256: 8e9dd5c5f30bf1889835189bd255feba85ca0fb3c47c595846c370b1bfa54ac1
Contents?: true
Size: 1.16 KB
Versions: 14
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Decidim module Admin # This command gets called when a feature is created from the admin panel. class UpdateFeature < Rectify::Command attr_reader :form, :feature # Public: Initializes the command. # # form - The form from which the data in this feature comes from. # feature - The feature to update. def initialize(form, feature) @manifest = feature.manifest @form = form @feature = feature end # Public: Creates the Feature. # # Broadcasts :ok if created, :invalid otherwise. def call return broadcast(:invalid) if form.invalid? transaction do update_feature run_hooks end broadcast(:ok) end private def update_feature @feature.update_attributes!( name: form.name, settings: form.settings, default_step_settings: form.default_step_settings, step_settings: form.step_settings, weight: form.weight ) end def run_hooks @manifest.run_hooks(:update, @feature) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems