class Paperclip::HasAttachedFile

def define_instance_getter

def define_instance_getter
  name = @name
  options = @options
  @klass.send :define_method, @name do |*args|
    ivar = "@attachment_#{name}"
    attachment = instance_variable_get(ivar)
    if attachment.nil?
      attachment = Attachment.new(name, self, options)
      instance_variable_set(ivar, attachment)
    end
    if args.length > 0
      attachment.to_s(args.first)
    else
      attachment
    end
  end
end