Sha256: fab0dcd768604b4b7b2f298207e893dcdc414a9fe6bd5c359ceaad332037954d

Contents?: true

Size: 845 Bytes

Versions: 6

Compression:

Stored size: 845 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A command with all the business logic when creating a scope.
    class CreateScope < Decidim::Commands::CreateResource
      fetch_form_attributes :name, :organization, :code, :scope_type
      # Public: Initializes the command.
      #
      # form - A form object with the params.
      # parent - A parent scope for the scope to be created
      def initialize(form, parent = nil)
        super(form)
        @parent = parent
      end

      protected

      attr_reader :parent

      def resource_class = Decidim::Scope

      def attributes = super.merge({ parent: })

      def extra_params
        {
          extra: {
            parent_name: parent.try(:name),
            scope_type_name: form.scope_type.try(:name)
          }
        }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/commands/decidim/admin/create_scope.rb
decidim-admin-0.29.0 app/commands/decidim/admin/create_scope.rb
decidim-admin-0.29.0.rc4 app/commands/decidim/admin/create_scope.rb
decidim-admin-0.29.0.rc3 app/commands/decidim/admin/create_scope.rb
decidim-admin-0.29.0.rc2 app/commands/decidim/admin/create_scope.rb
decidim-admin-0.29.0.rc1 app/commands/decidim/admin/create_scope.rb