Sha256: 853bc9cba7a06adb0e91eb506eeea71639e49c72437364cf439119c14e2ec3a1

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

class EomParent
  include Mongoid::Document

  embeds_one :child, class_name: 'EomChild'

  field :name, type: String
end

class EomChild
  include Mongoid::Document

  embedded_in :parent, class_name: 'EomParent'

  field :a, type: Integer, default: 0
  field :b, type: Integer, default: 0
end

# Models with associations with :class_name as a :: prefixed string

class EomCcParent
  include Mongoid::Document

  embeds_one :child, class_name: '::EomCcChild'
end

class EomCcChild
  include Mongoid::Document

  embedded_in :parent, class_name: '::EomCcParent'
end

# Models referencing other models which should not be loaded unless the
# respective association is referenced

autoload :EomDnlMissingChild, 'mongoid/association/embedded/embeds_one_dnl_models'

class EomDnlParent
  include Mongoid::Document

  embeds_one :child, class_name: 'EomDnlChild'
  embeds_one :missing_child, class_name: 'EomDnlMissingChild'
end

autoload :EomDnlMissingParent, 'mongoid/association/embedded/embeds_one_dnl_models'

class EomDnlChild
  include Mongoid::Document

  embedded_in :parent, class_name: 'EomDnlParent'
  embedded_in :missing_parent, class_name: 'EomDnlMissingParent'
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mongoid-7.0.13 spec/mongoid/association/embedded/embeds_one_models.rb
mongoid-7.0.12 spec/mongoid/association/embedded/embeds_one_models.rb
mongoid-7.0.11 spec/mongoid/association/embedded/embeds_one_models.rb
mongoid-7.0.10 spec/mongoid/association/embedded/embeds_one_models.rb
mongoid-7.0.8 spec/mongoid/association/embedded/embeds_one_models.rb
mongoid-7.0.7 spec/mongoid/association/embedded/embeds_one_models.rb
mongoid-7.0.6 spec/mongoid/association/embedded/embeds_one_models.rb
mongoid-7.0.5 spec/mongoid/association/embedded/embeds_one_models.rb
mongoid-7.0.4 spec/mongoid/association/embedded/embeds_one_models.rb