Module: Clevic::ManyField

Defined in:
lib/clevic/many_field.rb

Overview

Preliminary code for multi-valued fields. Not working yet.

Instance Method Summary collapse

Instance Method Details

#many(&block) ⇒ Object

x_to_many fields are by definition collections of other entities



6
7
8
9
10
11
12
13
14
15
# File 'lib/clevic/many_field.rb', line 6

def many( &block )
  if block
    many_view( &block )
  else
    many_view do |mb|
      # TODO should fetch this from one of the field definitions
      mb.plain related_attribute
    end
  end
end

#many_builderObject



17
18
19
# File 'lib/clevic/many_field.rb', line 17

def many_builder
  @many_view.builder
end

#many_fieldsObject



21
22
23
# File 'lib/clevic/many_field.rb', line 21

def many_fields
  many_builder.fields
end

#many_view(&block) ⇒ Object

return an instance of Clevic::View that represents the many items for this field



27
28
29
# File 'lib/clevic/many_field.rb', line 27

def many_view( &block )
  @many_view ||= View.new( :entity_class => related_class, &block )
end