Module: Redmine::NestedSet::ProjectNestedSet

Included in:
Project
Defined in:
lib/redmine/nested_set/project_nested_set.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/redmine/nested_set/project_nested_set.rb', line 23

def self.included(base)
  base.class_eval do
    belongs_to :parent, :class_name => self.name

    before_create :add_to_nested_set
    before_update(
      :move_in_nested_set,
      :if =>
        lambda {|project| project.parent_id_changed? || project.name_changed?}
    )
    before_destroy :destroy_children
  end
  base.extend ClassMethods
  base.send :include, Redmine::NestedSet::Traversing
end