Class: Formulario::Field::ExceptionalValue

Inherits:
Formulario::Field show all
Includes:
Enumerable
Defined in:
lib/formulario/fields/exceptional_value.rb

Constant Summary

Constants inherited from Formulario::Field

TYPES

Instance Attribute Summary collapse

Attributes inherited from Formulario::Field

#raw_value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Formulario::Field

#==, #blank?, default, #to_s, type_for, #value

Instance Attribute Details

#reasonsObject (readonly)

Returns the value of attribute reasons.



6
7
8
# File 'lib/formulario/fields/exceptional_value.rb', line 6

def reasons
  @reasons
end

Class Method Details

.for(raw_value, reasons: Undefined) ⇒ Object



8
9
10
# File 'lib/formulario/fields/exceptional_value.rb', line 8

def self.for(raw_value, reasons: Undefined)
  new(raw_value, reasons: reasons)
end

Instance Method Details

#each(&block) ⇒ Object



24
25
26
# File 'lib/formulario/fields/exceptional_value.rb', line 24

def each(&block)
  reasons.each(&block)
end

#exceptional?Boolean

Returns:



12
13
14
# File 'lib/formulario/fields/exceptional_value.rb', line 12

def exceptional?
  true
end

#exceptional_classObject



28
29
30
# File 'lib/formulario/fields/exceptional_value.rb', line 28

def exceptional_class
  self.class
end

#inspectObject



16
17
18
# File 'lib/formulario/fields/exceptional_value.rb', line 16

def inspect
  "#{self.class}[#{value} (#{reasons.join(' | ')})]"
end

#to_aObject



20
21
22
# File 'lib/formulario/fields/exceptional_value.rb', line 20

def to_a
  reasons
end