Class: Mongoid::Association::Embedded::EmbeddedIn

Inherits:
Object
  • Object
show all
Includes:
Buildable, Relatable
Defined in:
build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb,
build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in/proxy.rb,
build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in/binding.rb,
build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in/buildable.rb

Overview

The EmbeddedIn type association.

Defined Under Namespace

Modules: Buildable Classes: Binding, Proxy

Constant Summary collapse

ASSOCIATION_OPTIONS =

The options available for this type of association, in addition to the common ones.

Returns:

  • (Array<Symbol>)

    The extra valid options.

[
    :autobuild,
    :cyclic,
    :polymorphic,
    :touch,
].freeze
VALID_OPTIONS =

The complete list of valid options for this association, including the shared ones.

Returns:

  • (Array<Symbol>)

    The valid options.

(ASSOCIATION_OPTIONS + SHARED_OPTIONS).freeze

Constants included from Relatable

Relatable::PRIMARY_KEY_DEFAULT, Relatable::SHARED_OPTIONS

Instance Attribute Summary

Attributes included from Relatable

#name, #options, #parent_inclusions

Instance Method Summary collapse

Methods included from Buildable

#build

Methods included from Relatable

#==, #bindable?, #counter_cache_column_name, #create_relation, #destructive?, #extension, #foreign_key_check, #foreign_key_setter, #get_callbacks, #in_to?, #initialize, #inverse, #inverse_association, #inverse_class, #inverse_class_name, #inverse_setter, #inverse_type, #inverse_type_setter, #inverses, #many?, #one?, #path, #relation_class, #relation_class_name, #setter, #type_setter, #validate?

Methods included from Options

#as, #autobuilding?, #autosave, #cascading_callbacks?, #counter_cached?, #cyclic?, #dependent, #forced_nil_inverse?, #indexed?, #inverse_of, #order, #store_as, #touch_field, #type

Methods included from Constrainable

#convert_to_foreign_key

Instance Method Details

#embedded?true

Is this association type embedded?

Returns:

  • (true)

    Always true.



45
# File 'build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb', line 45

def embedded?; true; end

#keyString

The key that is used to get the attributes for the associated object.

Returns:

  • (String)

    The name of the association.



65
66
67
# File 'build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb', line 65

def key
  @key ||= name.to_s
end

#nested_builder(attributes, options) ⇒ Association::Nested::One

The nested builder object.

Parameters:

  • attributes (Hash)

    The attributes to use to build the association object.

  • options (Hash)

    The options for the association.

Returns:



89
90
91
# File 'build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb', line 89

def nested_builder(attributes, options)
  Nested::One.new(self, attributes, options)
end

#polymorphic?true | false

Is this association polymorphic?

Returns:

  • (true | false)

    Whether this association is polymorphic.



79
80
81
# File 'build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb', line 79

def polymorphic?
  !!@options[:polymorphic]
end

#primary_keynil

The primary key

Returns:

  • (nil)

    Not relevant for this association



50
# File 'build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb', line 50

def primary_key; end

#relationAssociation::Embedded::EmbeddedIn::Proxy

Get the association proxy class for this association type.

Returns:



72
73
74
# File 'build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb', line 72

def relation
  Proxy
end

#setup!self

Setup the instance methods, fields, etc. on the association owning class.

Returns:

  • (self)


36
37
38
39
40
# File 'build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb', line 36

def setup!
  setup_instance_methods!
  @owner_class.embedded = true
  self
end

#stores_foreign_key?false

Does this association type store the foreign key?

Returns:

  • (false)

    Always false.



55
# File 'build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb', line 55

def stores_foreign_key?; false; end

#validation_defaultfalse

The default for validating the association object.

Returns:

  • (false)

    Always false.



60
# File 'build/mongoid-8.1/lib/mongoid/association/embedded/embedded_in.rb', line 60

def validation_default; false; end