Class: AncestryAbstractResource
- Inherits:
-
AbstractResource
- Object
- ActiveRecord::Base
- AbstractResource
- AncestryAbstractResource
- Defined in:
- app/models/ancestry_abstract_resource.rb
Instance Attribute Summary
Attributes inherited from AbstractResource
Class Method Summary collapse
-
.arraying(options = {}, hash = nil) ⇒ Object
provided for ancestry ‘polluted’ tables ;).
Instance Method Summary collapse
Methods inherited from AbstractResource
#activate, #attach, #deactivate, #detach, filter, filter_proc, #lock_record?, #logit, logit, #resource_name, search
Class Method Details
.arraying(options = {}, hash = nil) ⇒ Object
provided for ancestry ‘polluted’ tables ;)
children and subtree are special ancestry related methods
# # #
10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/ancestry_abstract_resource.rb', line 10 def self.(={}, hash=nil) hash ||= arrange() arr = [] hash.each do |node, children| arr << node arr += (, children) unless children.nil? end arr end |
Instance Method Details
#possible_parents(order = 'name') ⇒ Object
21 22 23 24 |
# File 'app/models/ancestry_abstract_resource.rb', line 21 def possible_parents order='name' parents = self.( order: order) return new_record? ? parents : parents - subtree end |