Class: Mongoid::SleepingKingStudios::HasTree::Parent::Metadata

Inherits:
Concern::Metadata
  • Object
show all
Defined in:
lib/mongoid/sleeping_king_studios/has_tree/parent/metadata.rb

Overview

Stores information about a HasTree concern's parent relation.

Since:

  • 0.2.0

Instance Attribute Summary

Attributes inherited from Concern::Metadata

#name, #properties

Instance Method Summary collapse

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

#inverse_ofSymbol

The name of the tree's children relation. If no relation name is set, defaults to :children.

Returns:

  • (Symbol)

    The relation name.

Since:

  • 0.2.0


14
15
16
# File 'lib/mongoid/sleeping_king_studios/has_tree/parent/metadata.rb', line 14

def inverse_of
  fetch(:inverse_of, :children)
end

#inverse_of?Boolean

Returns True if a custom inverse relation name is set; otherwise false.

Returns:

  • (Boolean)

    True if a custom inverse relation name is set; otherwise false.

Since:

  • 0.2.0


20
21
22
# File 'lib/mongoid/sleeping_king_studios/has_tree/parent/metadata.rb', line 20

def inverse_of?
  !!self[:inverse_of]
end

#relation_nameSymbol

The name of the tree's parent relation. If no relation name is set, defaults to :parent.

Returns:

  • (Symbol)

    The relation name.

Since:

  • 0.2.0


28
29
30
# File 'lib/mongoid/sleeping_king_studios/has_tree/parent/metadata.rb', line 28

def relation_name
  fetch(:relation_name, :parent)
end

#relation_name?Boolean

Returns True if a custom relation name is set; otherwise false.

Returns:

  • (Boolean)

    True if a custom relation name is set; otherwise false.

Since:

  • 0.2.0


34
35
36
# File 'lib/mongoid/sleeping_king_studios/has_tree/parent/metadata.rb', line 34

def relation_name?
  !!self[:relation_name]
end