Class: Menus::Model::MenuItem
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Menus::Model::MenuItem
- Includes:
- Zen::Model::Helper
- Defined in:
- lib/zen/package/menus/lib/menus/model/menu_item.rb
Overview
Model used for managing individual menu items in a group.
Constant Summary
Constant Summary
Constants included from Zen::Model::Helper
Zen::Model::Helper::NoRegexpSupport
Class Method Summary (collapse)
-
+ (Mixed) search(query)
Searches for a set of menu items.
Instance Method Summary (collapse)
-
- (Object) parent_id=(parent_id)
Sets the ID of the parent navigation item but only if it's not empty and not the same as the current ID.
-
- (Object) validate
Specifies all validation rules that will be used when creating or updating a menu item.
Methods included from Zen::Model::Helper
Methods inherited from Sequel::Model
Class Method Details
+ (Mixed) search(query)
Searches for a set of menu items.
24 25 26 27 28 29 30 |
# File 'lib/zen/package/menus/lib/menus/model/menu_item.rb', line 24 def self.search(query) return filter( search_column(:name, query) | search_column(:html_class, query) | search_column(:html_id, query) ) end |
Instance Method Details
- (Object) parent_id=(parent_id)
Sets the ID of the parent navigation item but only if it's not empty and not the same as the current ID.
53 54 55 56 57 58 |
# File 'lib/zen/package/menus/lib/menus/model/menu_item.rb', line 53 def parent_id=(parent_id) if !(parent_id.respond_to?(:empty?) and !parent_id.empty?) \ and parent_id != self.id super(parent_id) end end |
- (Object) validate
Specifies all validation rules that will be used when creating or updating a menu item.
38 39 40 41 42 43 44 |
# File 'lib/zen/package/menus/lib/menus/model/menu_item.rb', line 38 def validate validates_presence([:name, :url]) validates_max_length(255, [:name, :url, :html_class, :html_id]) validates_integer([:sort_order, :parent_id]) validates_format(/^[a-zA-Z\-_0-9\s]*$/, :html_class) validates_format(/^[a-zA-Z\-_0-9]*$/ , :html_id) end |