Module: ErpTechSvcs::Utils::DefaultNestedSetMethods
- Included in:
- AuditLogType
- Defined in:
- lib/erp_tech_svcs/utils/default_nested_set_methods.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #leaf ⇒ Object
- #to_json_with_leaf(options = {}) ⇒ Object
- #to_label ⇒ Object
- #to_tree_hash(options = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/erp_tech_svcs/utils/default_nested_set_methods.rb', line 4 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#leaf ⇒ Object
12 13 14 |
# File 'lib/erp_tech_svcs/utils/default_nested_set_methods.rb', line 12 def leaf children.size == 0 end |
#to_json_with_leaf(options = {}) ⇒ Object
16 17 18 |
# File 'lib/erp_tech_svcs/utils/default_nested_set_methods.rb', line 16 def to_json_with_leaf( = {}) self.to_json_without_leaf(.merge(:methods => :leaf)) end |
#to_label ⇒ Object
8 9 10 |
# File 'lib/erp_tech_svcs/utils/default_nested_set_methods.rb', line 8 def to_label description end |
#to_tree_hash(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/erp_tech_svcs/utils/default_nested_set_methods.rb', line 21 def to_tree_hash(={}) additional_values = [:additional_values] || {} [:additional_values] = additional_values.merge({ :text => self.to_label, :leaf => self.leaf, :children => self.children.collect{|child| child.to_tree_hash()} }) tree_hash = self.to_hash() tree_hash[:iconCls] = [:icon_cls] if [:icon_cls] tree_hash end |