Class: Resourceful::AbstractFormData

Inherits:
Object
  • Object
show all
Defined in:
lib/resourceful/abstract_form_data.rb

Direct Known Subclasses

MultipartFormData, UrlencodedFormData

Instance Method Summary collapse

Constructor Details

#initialize(contents = {}) ⇒ AbstractFormData

Returns a new instance of AbstractFormData.



3
4
5
6
7
8
9
# File 'lib/resourceful/abstract_form_data.rb', line 3

def initialize(contents = {})
  @form_data = []
  
  contents.each do |k,v|
    add(k, v)
  end
end

Instance Method Details

#add(name, value) ⇒ Object

Add a name-value pair to this form data representation.

Parameters:

  • name (#to_s)

    The name of the new name-value pair.

  • value (#to_s)

    The value of the new name-value pair.



15
16
17
# File 'lib/resourceful/abstract_form_data.rb', line 15

def add(name, value)
  form_data << [name.to_s, value]
end

#rewindObject

Resets representation so that #read can be called again.


Form data representations do not need to be rewound so this is a no-op.



24
25
# File 'lib/resourceful/abstract_form_data.rb', line 24

def rewind
end