Sha256: 6235f867aba03a6360638c3a3da3378aeb3985a0b4ba8c8dec320458fe9ebe26

Contents?: true

Size: 792 Bytes

Versions: 2

Compression:

Stored size: 792 Bytes

Contents

# frozen_string_literal: true

module ActsAsRecursiveTree
  module ActsMacro
    ##
    # Configuration options are:
    #
    # * <tt>foreign_key</tt> - specifies the column name to use for tracking
    # of the tree (default: +parent_id+)
    def recursive_tree(parent_key: :parent_id, parent_type_column: nil, dependent: nil)
      class_attribute(:_recursive_tree_config, instance_writer: false)

      self._recursive_tree_config = Config.new(
        model_class: self,
        parent_key: parent_key.to_sym,
        parent_type_column: parent_type_column.try(:to_sym),
        dependent:
      )

      include ActsAsRecursiveTree::Model
      include ActsAsRecursiveTree::Associations
      include ActsAsRecursiveTree::Scopes
    end

    alias acts_as_tree recursive_tree
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_recursive_tree-4.1.0 lib/acts_as_recursive_tree/acts_macro.rb
acts_as_recursive_tree-4.0.0 lib/acts_as_recursive_tree/acts_macro.rb