Class: Mongoid::Relations::Metadata

Inherits:
Hash
  • Object
show all
Defined in:
lib/mongoid/core_ext/relations/metadata.rb

Instance Method Summary collapse

Instance Method Details

#inspectString

Since a lot of the information from the metadata is inferred and not explicitly stored in the hash, the inspection needs to be much more detailed.

Examples:

Inspect the metadata.

.inspect

Returns:

  • (String)

    Oodles of information in a nice format.

Since:

  • 2.0.0.rc.1



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mongoid/core_ext/relations/metadata.rb', line 14

def inspect
  %(#<Mongoid::Relations::Metadata
    autobuild:    #{autobuilding?}
    class_name:   #{class_name}
    cyclic:       #{cyclic.inspect}
    counter_cache:#{counter_cached?}
    dependent:    #{dependent.inspect}
    inverse_of:   #{inverse_of.inspect}
    key:          #{key}
    macro:        #{macro}
    name:         #{name}
    order:        #{order.inspect}
    polymorphic:  #{polymorphic?}
    relation:     #{relation}
    setter:       #{setter}
    versioned:    #{versioned?}>
  )
end

#inverse_relation_candidatesArray<Metdata>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the inverse relation candidates.

Examples:

Get the inverse relation candidates.

.inverse_relation_candidates

Returns:

  • (Array<Metdata>)

    The candidates.

Since:

  • 3.0.0



55
56
57
58
59
60
# File 'lib/mongoid/core_ext/relations/metadata.rb', line 55

def inverse_relation_candidates
  .select do |meta|
    next if meta.versioned? || meta.name == name
    meta.class_name == inverse_class_name
  end
end

#versioned?true, false

Is this relation using Mongoid’s internal versioning system?

Examples:

Is this relation versioned?

.versioned?

Returns:

  • (true, false)

    If the relation uses Mongoid versioning.

Since:

  • 2.1.0



41
42
43
# File 'lib/mongoid/core_ext/relations/metadata.rb', line 41

def versioned?
  !!self[:versioned]
end