Sha256: b94c84ad72afc7265023781779fe3905057d2d06e9fcc8974d1d526aee0b17b0
Contents?: true
Size: 973 Bytes
Versions: 9
Compression:
Stored size: 973 Bytes
Contents
module Pageflow class EntryDuplicate < Struct.new(:original_entry) def create! create_entry copy_draft copy_memberships new_entry end def self.of(entry) new(entry) end private attr_reader :new_entry def create_entry @new_entry = Entry.create!(new_attributes) end def copy_draft original_entry.draft.copy do |revision| revision.entry = new_entry end end def copy_memberships original_entry.users.each do |member| new_entry.memberships.create(user: member) end end def new_attributes { title: new_title, account: original_entry.account, theming: original_entry.theming, features_configuration: original_entry.features_configuration, skip_draft_creation: true } end def new_title I18n.t('pageflow.entry.duplicated_title', title: original_entry.title) end end end
Version data entries
9 entries across 9 versions & 1 rubygems