Class: Mongoid::SleepingKingStudios::HasTree::CacheAncestry::Metadata
- Inherits:
-
Concern::Metadata
- Object
- Hash
- Concern::Metadata
- Mongoid::SleepingKingStudios::HasTree::CacheAncestry::Metadata
- Defined in:
- lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb
Overview
Stores information about a HasTree::CacheAncestry concern.
Instance Attribute Summary
Attributes inherited from Concern::Metadata
Instance Method Summary collapse
-
#children_name ⇒ Symbol
The name of the children relation for the tree.
-
#children_name? ⇒ Boolean
True if a custom children relation name is set; otherwise false.
-
#foreign_key ⇒ Symbol
The name of the field used to store ancestor references.
-
#parent_foreign_key ⇒ Symbol
The name of the field used to store the tree’s parent relation.
-
#parent_foreign_key_writer ⇒ Symbol
The writer for the tree’s parent relation id.
-
#parent_name ⇒ Symbol
The name of the parent relation for the tree.
-
#parent_name? ⇒ Boolean
True if a custom children relation name is set; otherwise false.
-
#parent_writer ⇒ Symbol
The writer for the tree’s parent relation.
-
#relation_name ⇒ Symbol
The name of the tree’s ancestors method.
-
#relation_name? ⇒ Boolean
True if a custom relation name is set; otherwise false.
Methods inherited from Concern::Metadata
#characterize, #initialize, #relation_key, #relation_key?
Constructor Details
This class inherits a constructor from Mongoid::SleepingKingStudios::Concern::Metadata
Instance Method Details
#children_name ⇒ Symbol
The name of the children relation for the tree.
13 14 15 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 13 def children_name self[:children_name] || :children end |
#children_name? ⇒ Boolean
Returns True if a custom children relation name is set; otherwise false.
19 20 21 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 19 def children_name? !!self[:children_name] end |
#foreign_key ⇒ Symbol
The name of the field used to store ancestor references. If no foreign key is set, uses the relation name and the field name to generate a key.
28 29 30 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 28 def foreign_key self[:foreign_key] || :"#{relation_name.to_s.singularize}_ids" end |
#parent_foreign_key ⇒ Symbol
The name of the field used to store the tree’s parent relation.
35 36 37 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 35 def parent_foreign_key :"#{parent_name}_id" end |
#parent_foreign_key_writer ⇒ Symbol
The writer for the tree’s parent relation id.
42 43 44 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 42 def parent_foreign_key_writer :"#{parent_name}_id=" end |
#parent_name ⇒ Symbol
The name of the parent relation for the tree.
49 50 51 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 49 def parent_name self[:parent_name] || :parent end |
#parent_name? ⇒ Boolean
Returns True if a custom children relation name is set; otherwise false.
55 56 57 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 55 def parent_name? !!self[:parent_name] end |
#parent_writer ⇒ Symbol
The writer for the tree’s parent relation.
62 63 64 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 62 def parent_writer :"#{parent_name}=" end |
#relation_name ⇒ Symbol
The name of the tree’s ancestors method. If no relation name is set, defaults to :ancestors.
70 71 72 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 70 def relation_name fetch(:relation_name, :ancestors) end |
#relation_name? ⇒ Boolean
Returns True if a custom relation name is set; otherwise false.
76 77 78 |
# File 'lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb', line 76 def relation_name? !!self[:relation_name] end |