Module: Yaks::Resource::HasFields

Included in:
Form, Form::Fieldset
Defined in:
lib/yaks/resource/has_fields.rb

Instance Method Summary collapse

Instance Method Details

#fields_flat(&block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/yaks/resource/has_fields.rb', line 10

def fields_flat(&block)
  return to_enum(__method__) unless block_given?
  fields.map do |field|
    next field if field.type.equal? :legend
    if field.respond_to?(:map_fields)
      field.map_fields(&block)
    else
      block.call(field)
    end
  end
end

#map_fields(&block) ⇒ Object



4
5
6
7
8
# File 'lib/yaks/resource/has_fields.rb', line 4

def map_fields(&block)
  with(
    fields: fields_flat(&block)
  )
end