Class: ActsAsRecursiveTree::Config
- Inherits:
-
Object
- Object
- ActsAsRecursiveTree::Config
- Defined in:
- lib/acts_as_recursive_tree/config.rb
Overview
Stores the configuration of one Model class
Instance Attribute Summary collapse
-
#depth_column ⇒ Object
readonly
Returns the value of attribute depth_column.
-
#parent_key ⇒ Object
readonly
Returns the value of attribute parent_key.
-
#parent_type_column ⇒ Object
readonly
Returns the value of attribute parent_type_column.
Instance Method Summary collapse
-
#initialize(model_class:, parent_key:, parent_type_column:, depth_column: :recursive_depth) ⇒ Config
constructor
A new instance of Config.
-
#primary_key ⇒ Symbol
Returns the primary key for the model class.
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_column ⇒ Object (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_key ⇒ Object (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_column ⇒ Object (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_key ⇒ Symbol
Returns the primary key for the model class.
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 |