Class: TreeMenuNodeDef

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ErpTechSvcs::Utils::DefaultNestedSetMethods
Defined in:
app/models/tree_menu_node_def.rb

Class Method Summary collapse

Instance Method Summary collapse

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.find_menu_roots( menu_short_name )
  where("parent_id = nil and menu_short_name  = menu_short_name")
end

Instance Method Details

#find_parent_textObject



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

#leafObject



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

Returns:

  • (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(options = {})
  self.to_json_without_leaf(options.merge(:methods => :leaf))
end