class ElFinder2::Command::Rm

Public Instance Methods

execute() click to toggle source
# File lib/el_finder2/command/rm.rb, line 4
def execute
  files = @targets.flat_map(&:self_and_descendants).uniq
  hashes = files.map(&:path_hash)
  files.map(&:destroy)

  render json: { removed: hashes }
end

Private Instance Methods

parse_params!(params) click to toggle source
# File lib/el_finder2/command/rm.rb, line 12
        def parse_params!(params)
  targets = params[:targets]
  fail ElFinder2::Error.new(%w(errCmdParams rm)) unless targets.present?

  @targets = targets
             .map(&method(:to_path))
             .map(&ElFinder2::File.method(:find_by_path))
             .compact
end