class ElFinder2::Command::Duplicate

Public Instance Methods

execute() click to toggle source
# File lib/el_finder2/command/duplicate.rb, line 4
def execute
  duplicate = @target.copy_to(@current)

  render json: {
    added: ActiveModel::ArraySerializer.new([duplicate]).as_json
  }
end

Private Instance Methods

parse_params!(params) click to toggle source
# File lib/el_finder2/command/duplicate.rb, line 12
        def parse_params!(params)
  current, target = params.values_at(:current, :target)
  fail ElFinder2::Error.new(%w(errCmdParams duplicate)) unless current.present? && target.present?

  current_path = to_path(current)
  target_path = to_path(target)

  @current = ElFinder2::Folder.find_by_path(current)
  @target = ElFinder2::File.find_by_path(target)

  fail ElFinder2::Error.new('errFileNotFound') unless @current && @target
end