class Mongoid::SleepingKingStudios::HasTree::CacheAncestry::Metadata
Stores information about a HasTree::CacheAncestry
concern.
Public Instance Methods
The name of the children relation for the tree.
@return [Symbol] The relation name.
# File lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb, line 13 def children_name self[:children_name] || :children end
@return [Boolean] True if a custom children relation name is set;
otherwise false.
# File lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb, line 19 def children_name? !!self[:children_name] end
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.
@return [Symbol] The field name.
# 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
The name of the field used to store the tree’s parent relation.
@return [Symbol] The method name.
# File lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb, line 35 def parent_foreign_key :"#{parent_name}_id" end
The writer for the tree’s parent relation id.
@return [Symbol] The method name.
# File lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb, line 42 def parent_foreign_key_writer :"#{parent_name}_id=" end
The name of the parent relation for the tree.
@return [Symbol] The relation name.
# File lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb, line 49 def parent_name self[:parent_name] || :parent end
@return [Boolean] True if a custom children relation name is set;
otherwise false.
# File lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb, line 55 def parent_name? !!self[:parent_name] end
The writer for the tree’s parent relation.
@return [Symbol] The method name.
# File lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb, line 62 def parent_writer :"#{parent_name}=" end
The name of the tree’s ancestors method. If no relation name is set, defaults to :ancestors.
@return [Symbol] The relation name.
# File lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb, line 70 def relation_name fetch(:relation_name, :ancestors) end
@return [Boolean] True if a custom relation name is set; otherwise
false.
# File lib/mongoid/sleeping_king_studios/has_tree/cache_ancestry/metadata.rb, line 76 def relation_name? !!self[:relation_name] end