Sha256: 86dd6dce3da51c8c601979d9c0b15918974a5ec8ee152d708fd7a4023f28b6a5

Contents?: true

Size: 865 Bytes

Versions: 19

Compression:

Stored size: 865 Bytes

Contents

class TreeMenuNodeDef < ActiveRecord::Base
  attr_protected :created_at, :updated_at

  acts_as_nested_set
  include ErpTechSvcs::Utils::DefaultNestedSetMethods

  def refers_to_ar_class?
    return (self.resource_class != nil) 
  end

  def find_parent_text
    parent_text = ''

    unless self.parent_id.nil?
      parent_text = self.parent.text
    end

    parent_text

  end

  def self.find_menu_roots( menu_short_name )
    where("parent_id = nil and menu_short_name  = menu_short_name")
  end

  def self.find_children(parent_id = nil)
    parent_id.to_i == 0 ? self.roots : find(parent_id).children
  end

  def leaf
    unknown? || children.size == 0
  end

  def to_json_with_leaf(options = {})
    self.to_json_without_leaf(options.merge(:methods => :leaf))
  end
  alias_method_chain :to_json, :leaf     
  
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
erp_app-4.2.0 app/models/tree_menu_node_def.rb
erp_app-4.0.0 app/models/tree_menu_node_def.rb
erp_app-3.1.16 app/models/tree_menu_node_def.rb
erp_app-3.1.15 app/models/tree_menu_node_def.rb
erp_app-3.1.14 app/models/tree_menu_node_def.rb
erp_app-3.1.13 app/models/tree_menu_node_def.rb
erp_app-3.1.12 app/models/tree_menu_node_def.rb
erp_app-3.1.11 app/models/tree_menu_node_def.rb
erp_app-3.1.10 app/models/tree_menu_node_def.rb
erp_app-3.1.9 app/models/tree_menu_node_def.rb
erp_app-3.1.8 app/models/tree_menu_node_def.rb
erp_app-3.1.7 app/models/tree_menu_node_def.rb
erp_app-3.1.6 app/models/tree_menu_node_def.rb
erp_app-3.1.5 app/models/tree_menu_node_def.rb
erp_app-3.1.4 app/models/tree_menu_node_def.rb
erp_app-3.1.3 app/models/tree_menu_node_def.rb
erp_app-3.1.2 app/models/tree_menu_node_def.rb
erp_app-3.1.1 app/models/tree_menu_node_def.rb
erp_app-3.1.0 app/models/tree_menu_node_def.rb