Class: Formulaic::Form

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

Defined Under Namespace

Classes: InvalidAttributeTypeError

Constant Summary

ATTRIBUTE_INPUT_MAP =
{
  ActiveSupport::TimeWithZone => Formulaic::Inputs::DateInput,
  Date => Formulaic::Inputs::DateInput,
  DateTime => Formulaic::Inputs::DateTimeInput,
  Array => Formulaic::Inputs::ArrayInput,
  String => Formulaic::Inputs::StringInput,
  Symbol => Formulaic::Inputs::StringInput,
  1.class => Formulaic::Inputs::StringInput,
  Float => 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



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

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

Instance Method Details

#fillObject



24
25
26
# File 'lib/formulaic/form.rb', line 24

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