Class: Praxis::Handlers::WWWForm

Inherits:
Object
  • Object
show all
Defined in:
lib/praxis/handlers/www_form.rb

Instance Method Summary collapse

Constructor Details

#initializeWWWForm

Returns a new instance of WWWForm.



11
12
13
# File 'lib/praxis/handlers/www_form.rb', line 11

def initialize
  require 'rack' # superfluous, but might as well be safe
end

Instance Method Details

#generate(structured_data) ⇒ Object

Generate a URL-encoded WWW form from structured data. Not implemented since this format is not very useful for a response body.



22
23
24
25
26
# File 'lib/praxis/handlers/www_form.rb', line 22

def generate(structured_data)
  return nil if structured_data.nil?

  URI.encode_www_form(structured_data)
end

#parse(entity) ⇒ Object

Parse a URL-encoded WWW form into structured data.



16
17
18
# File 'lib/praxis/handlers/www_form.rb', line 16

def parse(entity)
  ::Rack::Utils.parse_nested_query(entity)
end