Class: WithForm::ScopeForm
- Inherits:
-
Object
- Object
- WithForm::ScopeForm
- Includes:
- ActionView::Helpers::TranslationHelper
- Defined in:
- lib/with_form/scope_form.rb
Instance Method Summary collapse
- #attach_file(attribute, path, **options) ⇒ Object
- #click_button(action = nil, **options) ⇒ Object
- #fill_in(attribute, with:, **options) ⇒ Object
-
#initialize(scope:, page:) ⇒ ScopeForm
constructor
A new instance of ScopeForm.
- #label(attribute) ⇒ Object
- #select(value, from:, **options) ⇒ Object
- #submit(action = nil) ⇒ Object
- #unselect(value, from:, **options) ⇒ Object
Constructor Details
#initialize(scope:, page:) ⇒ ScopeForm
Returns a new instance of ScopeForm.
7 8 9 10 |
# File 'lib/with_form/scope_form.rb', line 7 def initialize(scope:, page:) @page = page @scope = scope end |
Instance Method Details
#attach_file(attribute, path, **options) ⇒ Object
24 25 26 |
# File 'lib/with_form/scope_form.rb', line 24 def attach_file(attribute, path, **) @page.attach_file label(attribute), path, ** end |
#click_button(action = nil, **options) ⇒ Object
28 29 30 |
# File 'lib/with_form/scope_form.rb', line 28 def (action = nil, **) @page. submit(action), ** end |
#fill_in(attribute, with:, **options) ⇒ Object
12 13 14 |
# File 'lib/with_form/scope_form.rb', line 12 def fill_in(attribute, with:, **) @page.fill_in label(attribute), with: with, ** end |
#label(attribute) ⇒ Object
36 37 38 |
# File 'lib/with_form/scope_form.rb', line 36 def label(attribute) translate(attribute, scope: [:helpers, :label, @scope]) end |
#select(value, from:, **options) ⇒ Object
16 17 18 |
# File 'lib/with_form/scope_form.rb', line 16 def select(value, from:, **) @page.select value, from: label(from), ** end |
#submit(action = nil) ⇒ Object
32 33 34 |
# File 'lib/with_form/scope_form.rb', line 32 def submit(action = nil) translate(action || :submit, scope: [:helpers, :submit, @scope]) end |
#unselect(value, from:, **options) ⇒ Object
20 21 22 |
# File 'lib/with_form/scope_form.rb', line 20 def unselect(value, from:, **) @page.unselect value, from: label(from), ** end |