class ElFinder2::Command::Rename
Public Instance Methods
execute()
click to toggle source
# File lib/el_finder2/command/rename.rb, line 4 def execute @file.name = @name @file.save! render json: { added: ActiveModel::ArraySerializer.new([@file]).as_json, removed: [@hash] } end
Private Instance Methods
parse_params!(params)
click to toggle source
# File lib/el_finder2/command/rename.rb, line 14 def parse_params!(params) @name, target = params.values_at(:name, :target) fail ElFinder2::Error.new(%w(errCmdParams rename)) unless @name && target path = to_path(target) @file = ElFinder2::File.find_by_path(path) fail ElFinder2::Error.new('errFileNotFound') unless @file @hash = @file.path_hash end