Class: Webrat::FileField
Overview
:nodoc:
Instance Attribute Summary (collapse)
-
- (Object) content_type
Returns the value of attribute content_type.
Attributes inherited from Field
Attributes inherited from Element
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) digest_value
- - (Object) set(value, content_type = nil)
- - (Object) test_uploaded_file
- - (Object) to_query_string
Methods inherited from Field
#disabled?, field_class, field_classes, #id, inherited, #initialize, #label_text, load, #raise_error_if_disabled, #unset, xpath_search_excluding_hidden
Methods inherited from Element
#initialize, #inspect, load, load_all, #path
Constructor Details
This class inherits a constructor from Webrat::Field
Instance Attribute Details
- (Object) content_type
Returns the value of attribute content_type
331 332 333 |
# File 'lib/webrat/core/elements/field.rb', line 331 def content_type @content_type end |
Class Method Details
+ (Object) xpath_search
327 328 329 |
# File 'lib/webrat/core/elements/field.rb', line 327 def self.xpath_search ".//input[@type = 'file']" end |
Instance Method Details
- (Object) digest_value
339 340 341 |
# File 'lib/webrat/core/elements/field.rb', line 339 def digest_value @value ? Digest::MD5.hexdigest(self.object_id.to_s) : "" end |
- (Object) set(value, content_type = nil)
333 334 335 336 337 |
# File 'lib/webrat/core/elements/field.rb', line 333 def set(value, content_type = nil) @original_value = @value @content_type ||= content_type super(value) end |
- (Object) test_uploaded_file
348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/webrat/core/elements/field.rb', line 348 def test_uploaded_file return "" if @original_value.blank? case Webrat.configuration.mode when :rails if content_type ActionController::TestUploadedFile.new(@original_value, content_type) else ActionController::TestUploadedFile.new(@original_value) end when :rack, :merb Rack::Test::UploadedFile.new(@original_value, content_type) end end |
- (Object) to_query_string
343 344 345 346 |
# File 'lib/webrat/core/elements/field.rb', line 343 def to_query_string @value.nil? ? set("") : set(digest_value) super end |