Sha256: ddf147da5907b88476834047eb759f7ec44aa8ee5f86ecc647350b0f52589a9b

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 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: dependent
      )

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

    alias acts_as_tree recursive_tree
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_recursive_tree-3.5.0 lib/acts_as_recursive_tree/acts_macro.rb