Sha256: 2c33eeeda040249683456c026c27a0ca4aacf0af80072d866b61f0cb0054de3f

Contents?: true

Size: 853 Bytes

Versions: 54

Compression:

Stored size: 853 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Pages
    module Admin
      # This command is executed when the user changes a Page from the admin
      # panel.
      class UpdatePage < Rectify::Command
        # Initializes a UpdatePage Command.
        #
        # form - The form from which to get the data.
        # page - The current instance of the page to be updated.
        def initialize(form, page)
          @form = form
          @page = page
        end

        # Updates the page if valid.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          return broadcast(:invalid) if @form.invalid?

          update_page
          broadcast(:ok)
        end

        private

        def update_page
          @page.update_attributes!(body: @form.body)
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 2 rubygems

Version Path
decidim-pages-0.9.3 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.9.2 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.9.1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.9.0 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.8.4 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.8.3 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.8.2 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.8.1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.8.0 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.7.4 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.7.3 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.7.2 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.7.1 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.7.0 app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.6.8 app/commands/decidim/pages/admin/update_page.rb
decidim-0.6.8 decidim-pages/app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.6.7 app/commands/decidim/pages/admin/update_page.rb
decidim-0.6.7 decidim-pages/app/commands/decidim/pages/admin/update_page.rb
decidim-pages-0.6.6 app/commands/decidim/pages/admin/update_page.rb
decidim-0.6.6 decidim-pages/app/commands/decidim/pages/admin/update_page.rb