Class: Formulario::Field::Collection

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

Constant Summary

Constants inherited from Formulario::Field

TYPES

Instance Attribute Summary

Attributes inherited from Formulario::Field

#raw_value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Formulario::Field

#==, #blank?, default, #exceptional_class, for, #inspect, #to_s, type_for, #value

Class Method Details

.[](type) ⇒ Object



6
7
8
9
10
# File 'lib/formulario/fields/collection.rb', line 6

def self.[](type)
  Class.new(self).tap { |typed_class|
    typed_class.fields_type = type
  }
end

Instance Method Details

#each(&block) ⇒ Object



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

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

#exceptional?Boolean

Returns:



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

def exceptional?
  fields.any?(&:exceptional?)
end

#fieldsObject



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

def fields
  raw_value
end

#valuesObject



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

def values
  map(&:value)
end