Module: Formulaic::Dsl

Defined in:
lib/formulaic/dsl.rb

Instance Method Summary collapse

Instance Method Details

#fill_form(model_name, action = :new, attributes) ⇒ Object


3
4
5
# File 'lib/formulaic/dsl.rb', line 3

def fill_form(model_name, action = :new, attributes)
  Form.new(model_name, action, attributes).fill
end

#fill_form_and_submit(model_name, action = :new, attributes) ⇒ Object


7
8
9
10
11
12
# File 'lib/formulaic/dsl.rb', line 7

def fill_form_and_submit(model_name, action = :new, attributes)
  form_action_to_submit_action = { new: :create, edit: :update }
  fill_form(model_name, action, attributes)
  submit_action = form_action_to_submit_action[action] || action
  click_on submit(model_name, submit_action)
end

#input(model_name, field, action = :new) ⇒ Object


14
15
16
# File 'lib/formulaic/dsl.rb', line 14

def input(model_name, field, action = :new)
  Label.new(model_name, field, action).to_str
end

#submit(model_class, action = :create) ⇒ Object


18
19
20
21
22
23
# File 'lib/formulaic/dsl.rb', line 18

def submit(model_class, action = :create)
  I18n.t "#{model_class}.#{action}",
         scope: [:helpers, :submit],
         model: model_class.to_s.humanize,
         default: action
end