Class: Formulaic::Form

Inherits:
Object
  • Object
show all
Defined in:
lib/formulaic/form.rb

Defined Under Namespace

Classes: InvalidAttributeTypeError

Constant Summary collapse

ATTRIBUTE_INPUT_MAP =
{
  ActiveSupport::TimeWithZone => Formulaic::Inputs::DateInput,
  Date => Formulaic::Inputs::DateInput,
  Array => Formulaic::Inputs::ArrayInput,
  String => Formulaic::Inputs::StringInput,
  Fixnum => Formulaic::Inputs::StringInput,
  TrueClass => Formulaic::Inputs::BooleanInput,
  FalseClass => Formulaic::Inputs::BooleanInput,
  File => Formulaic::Inputs::FileInput,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(model_name, action, attributes) ⇒ Form

Returns a new instance of Form.



16
17
18
19
# File 'lib/formulaic/form.rb', line 16

def initialize(model_name, action, attributes)
  @action = action
  @inputs = build_inputs(model_name, attributes)
end

Instance Method Details

#fillObject



21
22
23
# File 'lib/formulaic/form.rb', line 21

def fill
  @inputs.each { |input| input.fill }
end