Class: ActsAsRecursiveTree::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_recursive_tree/config.rb

Overview

Stores the configuration of one Model class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_class:, parent_key:, parent_type_column:, depth_column: :recursive_depth) ⇒ Config

Returns a new instance of Config.



8
9
10
11
12
13
# File 'lib/acts_as_recursive_tree/config.rb', line 8

def initialize(model_class:, parent_key:, parent_type_column:, depth_column: :recursive_depth)
  @model_class        = model_class
  @parent_key         = parent_key
  @parent_type_column = parent_type_column
  @depth_column       = depth_column
end

Instance Attribute Details

#depth_columnObject (readonly)

Returns the value of attribute depth_column.



6
7
8
# File 'lib/acts_as_recursive_tree/config.rb', line 6

def depth_column
  @depth_column
end

#parent_keyObject (readonly)

Returns the value of attribute parent_key.



6
7
8
# File 'lib/acts_as_recursive_tree/config.rb', line 6

def parent_key
  @parent_key
end

#parent_type_columnObject (readonly)

Returns the value of attribute parent_type_column.



6
7
8
# File 'lib/acts_as_recursive_tree/config.rb', line 6

def parent_type_column
  @parent_type_column
end

Instance Method Details

#primary_keySymbol

Returns the primary key for the model class.

Returns:

  • (Symbol)


18
19
20
# File 'lib/acts_as_recursive_tree/config.rb', line 18

def primary_key
  @primary_key ||= @model_class.primary_key.to_sym
end