Sha256: 661b5f9136e2a01988b84d6f7ebc61521b3b1244911141f6c42d12eea7d42e07

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

#:nodoc:
module CustomFields
  #:nodoc:
  module Models
    ##
    # Model that represents a single custom field group. This model has
    # the following relations:
    #
    # * custom fields (one to many, ordered by "sort_order")
    # * sections (many to many)
    #
    # When creating or saving a group you are required to specify a "name" field.
    # This field may also be no longer than 255 characters.
    #
    # @author Yorick Peterse
    # @since  0.1
    #
    class CustomFieldGroup < Sequel::Model
      one_to_many(
        :custom_fields, 
        :class => "CustomFields::Models::CustomField", 
        :order => :sort_order
      )

      many_to_many(
        :sections, 
        :class => "Sections::Models::Section"
      )
      
      ##
      # Validates rules used whenever the model is created or saved.
      #
      # @author Yorick Peterse
      # @since  0.1
      #
      def validate
        validates_presence        :name
        validates_max_length 255, :name
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zen-0.2.4.1 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb
zen-0.2.4 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb
zen-0.2.3 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb
zen-0.2 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb