Sha256: 96c556571131dedeb2107bda4eb74a999c5e2903b011d33689567a05bb15dd8e

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

class Pulitzer::CloneVersion
  attr_accessor :version, :action, :new_version

  def initialize(version, new_version)
    self.version      = version
    self.new_version  = new_version
  end

  def call
    version.content_elements.each do |ce|
      element = ce.dup
      clone_image(ce, element)
      element.version_id = nil
      new_version.content_elements << element
    end
    version.post_tags.each do |pt|
      post_tag = pt.dup
      post_tag.version_id = nil
      new_version.post_tags << post_tag
    end
  end

private
  def clone_image(original, destination)
    if original.image.file && original.image.file.exists?
      destination.remote_image_url = original.image.url
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pulitzer-0.1.10 app/interactions/pulitzer/clone_version.rb