Class: Formulario::Field
- Inherits:
-
Object
show all
- Defined in:
- lib/formulario/fields.rb,
lib/formulario/fields/date.rb,
lib/formulario/fields/time.rb,
lib/formulario/fields/blank.rb,
lib/formulario/fields/field.rb,
lib/formulario/fields/float.rb,
lib/formulario/fields/string.rb,
lib/formulario/fields/boolean.rb,
lib/formulario/fields/integer.rb,
lib/formulario/fields/collection.rb,
lib/formulario/fields/form_field.rb,
lib/formulario/fields/exceptional_value.rb,
lib/formulario/fields/unvalidated_field.rb,
lib/formulario/fields/default_time_field.rb
Defined Under Namespace
Classes: Blank, Boolean, Collection, Date, DefaultTimeField, ExceptionalValue, Float, FormField, Integer, String, Time, UnvalidatedField
Constant Summary
collapse
- TYPES =
{
String => Formulario::Field::String,
:string => Formulario::Field::String,
Integer => Formulario::Field::Integer,
:integer => Formulario::Field::Integer,
Boolean => Formulario::Field::Boolean,
:boolean => Formulario::Field::Boolean,
Time => Formulario::Field::Time,
:time => Formulario::Field::Time,
Date => Formulario::Field::Date,
:date => Formulario::Field::Date,
Collection => Formulario::Field::Collection,
:collection => Formulario::Field::Collection,
:array => Formulario::Field::Collection,
}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#raw_value ⇒ Object
Returns the value of attribute raw_value.
23
24
25
|
# File 'lib/formulario/fields/field.rb', line 23
def raw_value
@raw_value
end
|
Class Method Details
.default ⇒ Object
44
45
46
|
# File 'lib/formulario/fields/field.rb', line 44
def self.default
Blank.new
end
|
.for(raw_value) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/formulario/fields/field.rb', line 25
def self.for(raw_value)
if raw_value.is_a?(Field)
raw_value
elsif ::Formulario::Utils.empty?(raw_value)
default
else
build(raw_value)
end
end
|
.type_for(field_type) ⇒ Object
19
20
21
|
# File 'lib/formulario/fields/field.rb', line 19
def self.type_for(type)
TYPES.fetch(type)
end
|
Instance Method Details
#==(other) ⇒ Object
69
70
71
72
|
# File 'lib/formulario/fields/field.rb', line 69
def ==(other)
new_other = Field.for(other)
value == new_other.value
end
|
52
53
54
|
# File 'lib/formulario/fields/field.rb', line 52
def blank?
false
end
|
#exceptional? ⇒ Boolean
48
49
50
|
# File 'lib/formulario/fields/field.rb', line 48
def exceptional?
false
end
|
#exceptional_class ⇒ Object
#inspect ⇒ Object
65
66
67
|
# File 'lib/formulario/fields/field.rb', line 65
def inspect
"#{self.class}[#{to_s}]"
end
|
#to_s ⇒ Object
Also known as:
to_str
60
61
62
|
# File 'lib/formulario/fields/field.rb', line 60
def to_s
value.to_s
end
|
#value ⇒ Object
56
57
58
|
# File 'lib/formulario/fields/field.rb', line 56
def value
raw_value
end
|