Sha256: e600403a1c4ead9089726ea4260ab1a88612b1349145db687147f1dad07bd73b

Contents?: true

Size: 742 Bytes

Versions: 3

Compression:

Stored size: 742 Bytes

Contents

module Clevic

  # Preliminary code for multi-valued fields. Not working yet.
  module ManyField
    # x_to_many fields are by definition collections of other entities
    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
    
    def many_builder
      @many_view.builder
    end
    
    def many_fields
      many_builder.fields
    end
    
    # return an instance of Clevic::View that represents the many items
    # for this field
    def many_view( &block )
      @many_view ||= View.new( :entity_class => related_class, &block )
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clevic-0.13.0.b9 lib/clevic/many_field.rb
clevic-0.13.0.b6 lib/clevic/many_field.rb
clevic-0.13.0.b5 lib/clevic/many_field.rb