77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/xylem.rb', line 77
def self.acts_as_tree(options = {})
config = {
counter_cache: options[:counter_cache] || nil,
dependent: options[:destroy] || :destroy,
touch: options[:touch] || false
}
has_many :children,
class_name: name,
foreign_key: :parent_id,
dependent: config[:dependent],
inverse_of: :parent
belongs_to :parent,
class_name: name,
counter_cache: config[:counter_cache],
touch: config[:touch],
inverse_of: :children
extend Xylem::ClassMethods
include Xylem::InstanceMethods
end
|