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,
  DateTime => Formulaic::Inputs::DateTimeInput,
  Array => Formulaic::Inputs::ArrayInput,
  String => Formulaic::Inputs::StringInput,
  Fixnum => 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.



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

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

Instance Method Details

#fillObject



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

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