Sha256: f262a6fce363b51cd6b1ce6b978e59b514b84c563f72aba54a8744e7d2fff940

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

#:nodoc:
module CustomFields
  #:nodoc:
  module Model
    ##
    # 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::Model::CustomField", 
        :order => :sort_order
      )

      many_to_many(:sections, :class => "Sections::Model::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 # CustomFieldGroup
  end # Model
end # CustomFields

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zen-0.2.8 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb
zen-0.2.7 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb
zen-0.2.6.1 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb
zen-0.2.6 lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb