Class: TreeMenuNodeDef
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TreeMenuNodeDef
- Includes:
- ErpTechSvcs::Utils::DefaultNestedSetMethods
- Defined in:
- app/models/tree_menu_node_def.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find_parent_text ⇒ Object
- #leaf ⇒ Object
- #refers_to_ar_class? ⇒ Boolean
- #to_json_with_leaf(options = {}) ⇒ Object
Class Method Details
.find_children(parent_id = nil) ⇒ Object
26 27 28 |
# File 'app/models/tree_menu_node_def.rb', line 26 def self.find_children(parent_id = nil) parent_id.to_i == 0 ? self.roots : find(parent_id).children end |
.find_menu_roots(menu_short_name) ⇒ Object
22 23 24 |
# File 'app/models/tree_menu_node_def.rb', line 22 def self.( ) where("parent_id = nil and menu_short_name = menu_short_name") end |
Instance Method Details
#find_parent_text ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/tree_menu_node_def.rb', line 11 def find_parent_text parent_text = '' unless self.parent_id.nil? parent_text = self.parent.text end parent_text end |
#leaf ⇒ Object
30 31 32 |
# File 'app/models/tree_menu_node_def.rb', line 30 def leaf unknown? || children.size == 0 end |
#refers_to_ar_class? ⇒ Boolean
7 8 9 |
# File 'app/models/tree_menu_node_def.rb', line 7 def refers_to_ar_class? return (self.resource_class != nil) end |
#to_json_with_leaf(options = {}) ⇒ Object
34 35 36 |
# File 'app/models/tree_menu_node_def.rb', line 34 def to_json_with_leaf( = {}) self.to_json_without_leaf(.merge(:methods => :leaf)) end |