Sha256: 783e91dc362248bfb7adb3035ed1db50cdb83803fa5abf98eb6fae0829c20498

Contents?: true

Size: 778 Bytes

Versions: 4

Compression:

Stored size: 778 Bytes

Contents

#:nodoc:
module Menus
  #:nodoc:
  module Models
    ##
    # Model used for managing individual menu items in a group.
    # This model uses the following plugins:
    #
    # * tree
    #
    # @author Yorick Peterse
    # @since  0.2a
    #
    class MenuItem < Sequel::Model
      plugin :tree, :order => :order

      ##
      # Specifies all validation rules that will be used when creating or updating a 
      # menu item.
      #
      # @author Yorick Peterse
      # @since  0.2a
      #
      def validate
        validates_presence :name
        validates_integer  [:order, :parent_id]
        
        # Prevent people from entering random crap for class and ID names
        validates_format(/^[a-zA-Z\-_0-9]*/, [:css_class, :css_id])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zen-0.2.4.1 lib/zen/package/menus/lib/menus/model/menu_item.rb
zen-0.2.4 lib/zen/package/menus/lib/menus/model/menu_item.rb
zen-0.2.3 lib/zen/package/menus/lib/menus/model/menu_item.rb
zen-0.2 lib/zen/package/menus/lib/menus/model/menu_item.rb