class Chop::Form::SingleFile

Public Instance Methods

fill_in!() click to toggle source
# File lib/chop/form.rb, line 180
def fill_in!
  assert_single_file!
  field.set file_path
end
matches?() click to toggle source
# File lib/chop/form.rb, line 176
def matches?
  field[:type] == "file" && !field[:multiple]
end

Private Instance Methods

assert_single_file!() click to toggle source
# File lib/chop/form.rb, line 193
def assert_single_file!
  if value.include?(" ")
    raise TypeError.new("Cannot attach multiple files to file field '#{label}' without the multiple attribute present")
  end
end
file_path() click to toggle source
# File lib/chop/form.rb, line 187
def file_path
  ::File.expand_path(::File.join(path, value)).tap do |path|
    ::File.open(path){} # raise Errno::ENOENT if file doesn't exist
  end
end