Sha256: 4876786770505a46bae37b847dfd796addbd168503335174108e62063fe03088

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

require 'with_advisory_lock'
require 'closure_tree/support'
require 'closure_tree/hierarchy_maintenance'
require 'closure_tree/model'
require 'closure_tree/finders'
require 'closure_tree/hash_tree'
require 'closure_tree/digraphs'
require 'closure_tree/deterministic_ordering'
require 'closure_tree/numeric_deterministic_ordering'

module ClosureTree
  module ActsAsTree
    def acts_as_tree(options = {})
      class_attribute :_ct
      self._ct = ClosureTree::Support.new(self, options)

      # Auto-inject the hierarchy table
      # See https://github.com/patshaughnessy/class_factory/blob/master/lib/class_factory/class_factory.rb
      class_attribute :hierarchy_class
      self.hierarchy_class = _ct.hierarchy_class_for_model

      # tests fail if you include Model before HierarchyMaintenance wtf
      include ClosureTree::HierarchyMaintenance
      include ClosureTree::Model
      include ClosureTree::Finders
      include ClosureTree::HashTree
      include ClosureTree::Digraphs

      include ClosureTree::DeterministicOrdering if _ct.order_option?
      include ClosureTree::NumericDeterministicOrdering if _ct.order_is_numeric?
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
closure_tree-4.2.8 lib/closure_tree/acts_as_tree.rb
closure_tree-4.2.7 lib/closure_tree/acts_as_tree.rb
closure_tree-4.2.6 lib/closure_tree/acts_as_tree.rb
closure_tree-4.2.5 lib/closure_tree/acts_as_tree.rb
closure_tree-4.2.4 lib/closure_tree/acts_as_tree.rb
closure_tree-4.2.3 lib/closure_tree/acts_as_tree.rb
closure_tree-4.2.2 lib/closure_tree/acts_as_tree.rb
closure_tree-4.2.1 lib/closure_tree/acts_as_tree.rb
closure_tree-4.2.0 lib/closure_tree/acts_as_tree.rb