Class: Decidim::Admin::UpdateFeature

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-admin/app/commands/decidim/admin/update_feature.rb

Overview

This command gets called when a feature is created from the admin panel.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form, feature) ⇒ UpdateFeature

Public: Initializes the command.

form - The form from which the data in this feature comes from. feature - The feature to update.



13
14
15
16
17
# File 'decidim-admin/app/commands/decidim/admin/update_feature.rb', line 13

def initialize(form, feature)
  @manifest = feature.manifest
  @form = form
  @feature = feature
end

Instance Attribute Details

#featureObject (readonly)

Returns the value of attribute feature.



7
8
9
# File 'decidim-admin/app/commands/decidim/admin/update_feature.rb', line 7

def feature
  @feature
end

#formObject (readonly)

Returns the value of attribute form.



7
8
9
# File 'decidim-admin/app/commands/decidim/admin/update_feature.rb', line 7

def form
  @form
end

Instance Method Details

#callObject

Public: Creates the Feature.

Broadcasts :ok if created, :invalid otherwise.



22
23
24
25
26
27
28
29
30
31
# File 'decidim-admin/app/commands/decidim/admin/update_feature.rb', line 22

def call
  return broadcast(:invalid) if form.invalid?

  transaction do
    update_feature
    run_hooks
  end

  broadcast(:ok)
end