Class: AncestryAbstractResource

Inherits:
AbstractResource show all
Defined in:
app/models/ancestry_abstract_resource.rb

Instance Attribute Summary

Attributes inherited from AbstractResource

#current_user

Class Method Summary collapse

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.arraying(options={}, hash=nil)
  hash ||= arrange(options)

  arr = []
  hash.each do |node, children|
    arr << node
    arr += arraying(options, 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.arraying( order: order)
  return new_record? ? parents : parents - subtree
end