Class: Repost::Senpai
Constant Summary collapse
- DEFAULT_SUBMIT_BUTTON_TEXT =
'Continue'- DEFAULT_CHARSET =
'UTF-8'- OVERRIDE_METHODS =
Browsers only submit forms via GET or POST; other verbs are sent as POST with a Rails-style "_method" override field.
%w[put patch delete].freeze
Instance Method Summary collapse
-
#initialize(url, params: {}, options: {}) ⇒ Senpai
constructor
A new instance of Senpai.
- #perform ⇒ Object
Methods inherited from Action
Constructor Details
#initialize(url, params: {}, options: {}) ⇒ Senpai
Returns a new instance of Senpai.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/repost/senpai.rb', line 12 def initialize(url, params: {}, options: {}) @url = url @params = params @options = @method = .fetch(:method, :post).to_s.downcase @authenticity_token = .fetch(:authenticity_token, nil) @charset = .fetch(:charset, DEFAULT_CHARSET) @form_id = .fetch(:form_id, generated_form_id) @autosubmit = .fetch(:autosubmit, true) @autosubmit_nonce = .fetch(:autosubmit_nonce, nil) @section_classes = .dig(:decor, :section, :classes) @section_html = .dig(:decor, :section, :html) @submit_classes = .dig(:decor, :submit, :classes) @submit_text = .dig(:decor, :submit, :text) || DEFAULT_SUBMIT_BUTTON_TEXT end |
Instance Method Details
#perform ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/repost/senpai.rb', line 28 def perform compiled_body = if autosubmit form_body << auto_submit_script << no_script else form_body << submit_section end form_head << compiled_body << end |