Class: Pulitzer::PostTypeVersionsController::ClonePostWithVersionElements

Inherits:
Object
  • Object
show all
Defined in:
app/interactions/pulitzer/post_type_versions_controller/clone_post_with_version_elements.rb

Instance Method Summary collapse

Constructor Details

#initialize(post, new_post_type_version) ⇒ ClonePostWithVersionElements

Returns a new instance of ClonePostWithVersionElements.



3
4
5
6
# File 'app/interactions/pulitzer/post_type_versions_controller/clone_post_with_version_elements.rb', line 3

def initialize(post, new_post_type_version)
  @post         = post
  @new_post_type_version  = new_post_type_version
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
# File 'app/interactions/pulitzer/post_type_versions_controller/clone_post_with_version_elements.rb', line 8

def call
  new_post = @new_post_type_version.posts.create(title: @post.title)
  @post.clonable_versions.each do |version|
    processing_version = new_post.create_processing_version
    Pulitzer::CloneVersion.new(version, processing_version).call
  end
end