Sha256: 8603838ad1e755d19efd4606f1802d9bcc39745380fc414a6cc4f22b6fb41c99
Contents?: true
Size: 978 Bytes
Versions: 44
Compression:
Stored size: 978 Bytes
Contents
# frozen_string_literal: true module Decidim module Blogs module Admin # This command is executed when the user changes a Blog from the admin # panel. class UpdatePost < Rectify::Command # Initializes a UpdateBlog Command. # # form - The form from which to get the data. # blog - The current instance of the page to be updated. def initialize(form, post) @form = form @post = post end # Updates the blog if valid. # # Broadcasts :ok if successful, :invalid otherwise. def call return broadcast(:invalid) if form.invalid? transaction do update_post! end broadcast(:ok, post) end private attr_reader :form, :post def update_post! post.update!( title: form.title, body: form.body ) end end end end end
Version data entries
44 entries across 44 versions & 1 rubygems