class Formulario::Field::FormField
Constants
- UndefinedFormFieldType
Attributes
form[R]
Public Class Methods
[](type)
click to toggle source
# File lib/formulario/fields/form_field.rb, line 6 def self.[](type) Class.new(self) do |typed_class| typed_class.type = type end end
default()
click to toggle source
# File lib/formulario/fields/form_field.rb, line 16 def self.default new(type.default) end
new(raw_value)
click to toggle source
Calls superclass method
Formulario::Field::new
# File lib/formulario/fields/form_field.rb, line 36 def initialize(raw_value) @form = if raw_value.is_a?(::Formulario::Form) raw_value else self.class.type.new(**raw_value) end super end
type()
click to toggle source
# File lib/formulario/fields/form_field.rb, line 12 def self.type @type end
Private Class Methods
build(raw_value)
click to toggle source
# File lib/formulario/fields/form_field.rb, line 48 def self.build(raw_value) raise UndefinedFormFieldType.new unless @type new(raw_value) end
type=(new_type)
click to toggle source
# File lib/formulario/fields/form_field.rb, line 54 def self.type=(new_type) @type = new_type end
Public Instance Methods
[](value)
click to toggle source
# File lib/formulario/fields/form_field.rb, line 32 def [](value) fields[value] end
exceptional?()
click to toggle source
# File lib/formulario/fields/form_field.rb, line 24 def exceptional? ! form.valid? end
fields()
click to toggle source
# File lib/formulario/fields/form_field.rb, line 28 def fields form.fields end
value()
click to toggle source
# File lib/formulario/fields/form_field.rb, line 20 def value form.params end
Private Instance Methods
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/formulario/fields/form_field.rb, line 58 def method_missing(name, *args, &block) return fields[name] if fields.has_key?(name) super end