Class: Dommy::Interaction::FormSubmission
- Inherits:
-
Object
- Object
- Dommy::Interaction::FormSubmission
- Defined in:
- lib/dommy/interaction/form_submission.rb
Overview
Collects successful form controls and resolves the effective method,
action, and enctype for a form submission. Stateless given the form and
submitter — it returns a plain data hash and makes no requests. The host
(Rack session) turns the result into navigation; a standalone Browser
dispatches a submit event instead. Method-override behavior is passed in
so core stays Rack-free.
Constant Summary collapse
- FORM_URLENCODED =
"application/x-www-form-urlencoded"- MULTIPART =
"multipart/form-data"- OVERRIDE_METHODS =
%w[PATCH PUT DELETE].freeze
Instance Method Summary collapse
-
#initialize(form, submitter, respect_method_override: false, method_override_param: "_method") ⇒ FormSubmission
constructor
A new instance of FormSubmission.
-
#submit! ⇒ Object
Returns { method:, url:, params:, enctype: }.
Constructor Details
#initialize(form, submitter, respect_method_override: false, method_override_param: "_method") ⇒ FormSubmission
Returns a new instance of FormSubmission.
16 17 18 19 20 21 |
# File 'lib/dommy/interaction/form_submission.rb', line 16 def initialize(form, submitter, respect_method_override: false, method_override_param: "_method") @form = form @submitter = submitter @respect_method_override = respect_method_override @method_override_param = method_override_param end |
Instance Method Details
#submit! ⇒ Object
Returns { method:, url:, params:, enctype: }.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dommy/interaction/form_submission.rb', line 24 def submit! method = form_method params = collect_params method = apply_method_override(method, params) params = apply_charset(params) { method: method, url: resolve_action(form_method), params: params, enctype: form_enctype } end |