Skip to content

Instantly share code, notes, and snippets.

@oleganza
Created May 6, 2009 16:27
Show Gist options
  • Save oleganza/107593 to your computer and use it in GitHub Desktop.
Save oleganza/107593 to your computer and use it in GitHub Desktop.
# I wonder why we still use File instance monkey-patching
# instead of a regular subclass/delegator?
# Every time you test uploaded files, you come up with a brand-new mock.
# Duh...
class UploadedFile < Delegator
attr_accessor :file, :mime_type, :original_filename
def initialize(file, mime_type, original_filename)
super(file)
@file = file
@mime_type = mime_type
@original_filename = original_filename
# ...
end
def __getobj__; @file; end # required by Delegator
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment