Module: Sunrise::Models::Structure::ClassMethods

Defined in:
lib/sunrise/models/structure.rb

Instance Method Summary collapse

Instance Method Details

#nested_set_options(mover = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sunrise/models/structure.rb', line 30

def nested_set_options(mover = nil)
  result = []
  
  roots.each do |root|
    result += root.self_and_descendants.map do |i|
      if mover.nil? || mover.new_record? || mover.move_possible?(i)
        [yield(i), i.id]
      end
    end.compact
  end
  result
end