Module: Redmine::NestedSet::IssueNestedSet

Included in:
Issue
Defined in:
lib/redmine/nested_set/issue_nested_set.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/redmine/nested_set/issue_nested_set.rb', line 21

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

    before_create :add_to_nested_set, :if => lambda {|issue| issue.parent.present?}
    after_create :add_as_root, :if => lambda {|issue| issue.parent.blank?}
    before_update :handle_parent_change, :if => lambda {|issue| issue.parent_id_changed?}
    before_destroy :destroy_children
  end
  base.extend ClassMethods
  base.send :include, Redmine::NestedSet::Traversing
end