Skip to content

Instantly share code, notes, and snippets.

@swarley
Created February 27, 2019 00:27
Show Gist options
  • Save swarley/7c18896c36918fb1b92dd38950f94d78 to your computer and use it in GitHub Desktop.
Save swarley/7c18896c36918fb1b92dd38950f94d78 to your computer and use it in GitHub Desktop.
if file.respond_to?(:read)
if spoiler
filename ||= File.basename(file.path)
filename = 'SPOILER_' + filename unless filename.start_with? 'SPOILER_'
end
# https://github.com/rest-client/rest-client/blob/v2.0.2/lib/restclient/payload.rb#L160
file.define_singleton_method(:original_filename) { filename } if filename
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment