class Formulario::Field

Constants

TYPES

Attributes

raw_value[R]

Public Class Methods

default() click to toggle source
# File lib/formulario/fields/field.rb, line 44
def self.default
  Blank.new
end
for(raw_value) click to toggle source
# 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
new(raw_value) click to toggle source
# File lib/formulario/fields/field.rb, line 84
def initialize(raw_value)
  @raw_value = raw_value
  freeze
end
type_for(type) click to toggle source
# File lib/formulario/fields/field.rb, line 19
def self.type_for(type)
  TYPES.fetch(type)
end

Private Class Methods

build(raw_value) click to toggle source
# File lib/formulario/fields/field.rb, line 80
def self.build(raw_value)
  new(raw_value)
end

Public Instance Methods

==(other) click to toggle source
# File lib/formulario/fields/field.rb, line 69
def ==(other)
  new_other = Field.for(other)
  value == new_other.value
end
blank?() click to toggle source
# File lib/formulario/fields/field.rb, line 52
def blank?
  false
end
exceptional?() click to toggle source
# File lib/formulario/fields/field.rb, line 48
def exceptional?
  false
end
exceptional_class() click to toggle source
# File lib/formulario/fields/field.rb, line 74
def exceptional_class
  ::Formulario::Field::ExceptionalValue
end
inspect() click to toggle source
# File lib/formulario/fields/field.rb, line 65
def inspect
  "#{self.class}[#{to_s}]"
end
to_s() click to toggle source
# File lib/formulario/fields/field.rb, line 60
def to_s
  value.to_s
end
Also aliased as: to_str
to_str()
Alias for: to_s
value() click to toggle source
# File lib/formulario/fields/field.rb, line 56
def value
  raw_value
end