Class: Repost::Senpai

Inherits:
Action
  • Object
show all
Defined in:
lib/repost/senpai.rb

Constant Summary collapse

DEFAULT_SUBMIT_BUTTON_TEXT =
'Continue'
DEFAULT_CHARSET =
'UTF-8'

Instance Method Summary collapse

Methods inherited from Action

perform

Constructor Details

#initialize(url, params: {}, options: {}) ⇒ Senpai

Returns a new instance of Senpai.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/repost/senpai.rb', line 6

def initialize(url, params: {}, options: {})
  @url                = url
  @params             = params
  @options            = options
  @method             = options.fetch(:method, :post)
  @authenticity_token = options.fetch(:authenticity_token, nil)
  @charset            = options.fetch(:charset, DEFAULT_CHARSET)
  @form_id            = options.fetch(:form_id, generated_form_id)
  @autosubmit         = options.fetch(:autosubmit, true)
  @autosubmit_nonce   = options.fetch(:autosubmit_nonce, nil)
  @section_classes    = options.dig(:decor, :section, :classes)
  @section_html       = options.dig(:decor, :section, :html)
  @submit_classes     = options.dig(:decor, :submit, :classes)
  @submit_text        = options.dig(:decor, :submit, :text) || DEFAULT_SUBMIT_BUTTON_TEXT
end

Instance Method Details

#performObject



22
23
24
25
26
27
28
29
# File 'lib/repost/senpai.rb', line 22

def perform
  compiled_body = if autosubmit
    form_body << auto_submit_script << no_script
  else
    form_body << submit_section
  end
  form_head << compiled_body << form_footer
end