repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/helpers.rb | spec/support/helpers.rb | # rubocop:todo all
module Helpers
# Reloads the specified model class.
#
# @param [ String | Symbol ] name Class name to reload.
def reload_model(name)
Object.class_eval do
remove_const(name)
end
load "spec/support/models/#{name.to_s.underscore}.rb"
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/crypt.rb | spec/support/crypt.rb | # frozen_string_literal: true
# rubocop:todo all
module Mongoid
# This module includes helpers for testing encryption.
module Crypt
shared_context 'with encryption' do
let(:mongocryptd_port) do
if ENV['MONGO_RUBY_DRIVER_MONGOCRYPTD_PORT'] &&
!ENV['MONGO_RUBY_DRIVER_MONGOCRYPTD_PORT'].e... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/spec_config.rb | spec/support/spec_config.rb | # frozen_string_literal: true
# rubocop:todo all
require 'singleton'
class SpecConfig
include Singleton
DEFAULT_MONGODB_URI = "mongodb://127.0.0.1:27017"
def initialize
if ENV['MONGODB_URI']
@uri_str = ENV['MONGODB_URI']
else
STDERR.puts "Environment variable 'MONGODB_URI' is not set, so t... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/authorization.rb | spec/support/authorization.rb | # frozen_string_literal: true
# rubocop:todo all
# Set up a root user so we can set up authentication on a database level.
MONGOID_ROOT_USER = Mongo::Auth::User.new(
database: Mongo::Database::ADMIN,
user: 'mongoid-user',
password: 'password',
roles: [
Mongo::Auth::Roles::USER_ADMIN_ANY_DATABASE,
Mongo... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/vehicle.rb | spec/support/models/vehicle.rb | # frozen_string_literal: true
# rubocop:todo all
class Vehicle
include Mongoid::Document
belongs_to :shipping_container
belongs_to :driver
embeds_many :crates
embeds_many :seats, cascade_callbacks: true
accepts_nested_attributes_for :driver
accepts_nested_attributes_for :shipping_container
accepts_n... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/seo.rb | spec/support/models/seo.rb | # frozen_string_literal: true
# rubocop:todo all
class Seo
include Mongoid::Document
include Mongoid::Timestamps
field :title, type: String
field :name, type: String, localize: true
field :desc, as: :description, type: String, localize: true
embedded_in :seo_tags, polymorphic: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/agency.rb | spec/support/models/agency.rb | # frozen_string_literal: true
# rubocop:todo all
class Agency
include Mongoid::Document
include Mongoid::Timestamps::Updated
has_many :agents, validate: false
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/circuit.rb | spec/support/models/circuit.rb | # frozen_string_literal: true
# rubocop:todo all
class Circuit
include Mongoid::Document
embeds_many :buses, order: [[ :saturday, :asc], [ :departure_time, :asc], [ :number, :asc ]]
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/seat.rb | spec/support/models/seat.rb | # frozen_string_literal: true
# rubocop:todo all
class Seat
include Mongoid::Document
embedded_in :vehicle
field :rating, type: Integer
embeds_many :armrests
before_create :set_rating
before_update :update_rating
private
def set_rating
self.rating ||= 100
end
def update_rating
self.r... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/kaleidoscope.rb | spec/support/models/kaleidoscope.rb | # frozen_string_literal: true
# rubocop:todo all
class Kaleidoscope
include Mongoid::Document
field :active, type: Mongoid::Boolean, default: true
scope :activated, -> { where(active: true) }
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/tag.rb | spec/support/models/tag.rb | # frozen_string_literal: true
# rubocop:todo all
class Tag
include Mongoid::Document
field :text, type: String
has_and_belongs_to_many :actors
has_and_belongs_to_many :articles
has_and_belongs_to_many :posts
has_and_belongs_to_many :related, class_name: "Tag", inverse_of: :related
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/target.rb | spec/support/models/target.rb | # frozen_string_literal: true
# rubocop:todo all
class Target
include Mongoid::Document
field :name, type: String
embedded_in :targetable, polymorphic: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/agent.rb | spec/support/models/agent.rb | # frozen_string_literal: true
# rubocop:todo all
class Agent
include Mongoid::Document
include Mongoid::Timestamps::Updated
field :title, type: String
field :number, type: String
field :dob, type: Time
embeds_many :names, as: :namable
embeds_one :address
belongs_to :game
belongs_to :agency, touch: tr... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/ordered_post.rb | spec/support/models/ordered_post.rb | # frozen_string_literal: true
# rubocop:todo all
class OrderedPost
include Mongoid::Document
field :title, type: String
field :rating, type: Integer
belongs_to :person
after_destroy do
person.title = 'Minus one ordered post.'
person.save!
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/child_doc.rb | spec/support/models/child_doc.rb | # frozen_string_literal: true
# rubocop:todo all
class ChildDoc
include Mongoid::Document
embedded_in :parent_doc
attr_writer :position
after_save :update_position
def position
existing_position = parent_doc.children_order.index(id)
existing_position ? existing_position + 1 : parent_doc.aspects.s... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/subscription.rb | spec/support/models/subscription.rb | # frozen_string_literal: true
# rubocop:todo all
class Subscription
include Mongoid::Document
has_many :packs, class_name: "ShippingPack"
field :packs_count, type: Integer
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/student.rb | spec/support/models/student.rb | # frozen_string_literal: true
# rubocop:todo all
class Student
include Mongoid::Document
belongs_to :school
field :name, type: String
field :grade, type: Integer, default: 3
after_destroy do |doc|
school.after_destroy_triggered = true if school
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/entry.rb | spec/support/models/entry.rb | # frozen_string_literal: true
# rubocop:todo all
class Entry
include Mongoid::Document
field :title, type: String
field :body, type: String
recursively_embeds_many
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/hole.rb | spec/support/models/hole.rb | # frozen_string_literal: true
# rubocop:todo all
class Hole
include Mongoid::Document
has_one :bolt, dependent: :destroy
has_one :threadlocker, dependent: :delete_all
has_one :sealer, dependent: :restrict_with_exception
has_many :nuts, dependent: :destroy
has_many :washers, dependent: :delete_all
has_ma... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/language.rb | spec/support/models/language.rb | # frozen_string_literal: true
# rubocop:todo all
class Language
include Mongoid::Document
field :name, type: String
embedded_in :translatable, polymorphic: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/mixed_drink.rb | spec/support/models/mixed_drink.rb | # frozen_string_literal: true
# rubocop:todo all
class MixedDrink
include Mongoid::Document
field :name
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/weapon.rb | spec/support/models/weapon.rb | # frozen_string_literal: true
# rubocop:todo all
class Weapon
include Mongoid::Document
field :name
belongs_to :player, inverse_of: :weapons
after_build do
self.name = "Holy Hand Grenade (#{player.frags})"
end
field :after_find_player
field :after_initialize_player
field :after_default_player, ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/pronunciation.rb | spec/support/models/pronunciation.rb | # frozen_string_literal: true
# rubocop:todo all
class Pronunciation
include Mongoid::Document
field :sound, type: String
embedded_in :word
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/array_field.rb | spec/support/models/array_field.rb | # frozen_string_literal: true
# rubocop:todo all
class ArrayField
include Mongoid::Document
field :af, type: Array
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/vertex.rb | spec/support/models/vertex.rb | # frozen_string_literal: true
# rubocop:todo all
class Vertex
include Mongoid::Document
has_and_belongs_to_many :parents, inverse_of: :children, class_name: 'Vertex'
has_and_belongs_to_many :children, inverse_of: :parents, class_name: 'Vertex'
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/answer.rb | spec/support/models/answer.rb | # frozen_string_literal: true
# rubocop:todo all
class Answer
include Mongoid::Document
embedded_in :question
field :position, type: Integer
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/preference.rb | spec/support/models/preference.rb | # frozen_string_literal: true
# rubocop:todo all
class Preference
include Mongoid::Document
field :name, type: String
field :value, type: String
field :ranking, type: Integer
has_and_belongs_to_many :people, validate: false
validates_length_of :name, minimum: 2, allow_nil: true
scope :posting, ->{ where(... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/exhibition.rb | spec/support/models/exhibition.rb | # frozen_string_literal: true
# rubocop:todo all
class Exhibition
include Mongoid::Document
has_many :exhibitors
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/book.rb | spec/support/models/book.rb | # frozen_string_literal: true
# rubocop:todo all
class Book
include Mongoid::Document
include Mongoid::Attributes::Dynamic
include Mongoid::Timestamps
field :title, type: String
field :chapters, type: Integer
belongs_to :series
belongs_to :person, autobuild: true
has_one :rating, as: :ratable, dependen... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/jar.rb | spec/support/models/jar.rb | # frozen_string_literal: true
# rubocop:todo all
class Jar
include Mongoid::Document
include Mongoid::Timestamps::Updated
field :_id, type: Integer, overwrite: true
has_many :cookies, class_name: "Cookie"
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/address_number.rb | spec/support/models/address_number.rb | # frozen_string_literal: true
# rubocop:todo all
class AddressNumber
include Mongoid::Document
field :country_code, type: Integer, default: 1
field :number
embedded_in :slave
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/record.rb | spec/support/models/record.rb | # frozen_string_literal: true
# rubocop:todo all
class Record
include Mongoid::Document
field :name, type: String
field :producers, type: Array
field :before_create_called, type: Mongoid::Boolean, default: false
field :before_save_called, type: Mongoid::Boolean, default: false
field :before_update_called,... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/contractor.rb | spec/support/models/contractor.rb | # frozen_string_literal: true
# rubocop:todo all
class Contractor
include Mongoid::Document
embedded_in :building
field :name, type: String
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/artist.rb | spec/support/models/artist.rb | # frozen_string_literal: true
# rubocop:todo all
class Artist
include Mongoid::Document
attr_accessor :before_add_called, :after_add_called, :before_add_referenced_called, :after_add_referenced_called, :before_remove_embedded_called, :after_remove_embedded_called, :before_remove_referenced_called, :after_remove_r... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/version.rb | spec/support/models/version.rb | # frozen_string_literal: true
# rubocop:todo all
class Version
include Mongoid::Document
field :number, type: Integer
embedded_in :memorable, polymorphic: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/event.rb | spec/support/models/event.rb | # frozen_string_literal: true
# rubocop:todo all
class Event
include Mongoid::Document
field :title
field :date, type: Date
has_and_belongs_to_many \
:administrators,
class_name: 'Person',
inverse_of: :administrated_events,
dependent: :nullify
belongs_to :owner
def self.each_day(start_dat... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/sealer.rb | spec/support/models/sealer.rb | # frozen_string_literal: true
# rubocop:todo all
class Sealer
include Mongoid::Document
belongs_to :hole
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/scribe.rb | spec/support/models/scribe.rb | # frozen_string_literal: true
# rubocop:todo all
class Scribe
include Mongoid::Document
field :name, type: String
embedded_in :owner
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/shelf.rb | spec/support/models/shelf.rb | # frozen_string_literal: true
# rubocop:todo all
class Shelf
include Mongoid::Document
field :level, type: Integer
recursively_embeds_one
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/threadlocker.rb | spec/support/models/threadlocker.rb | # frozen_string_literal: true
# rubocop:todo all
class Threadlocker
include Mongoid::Document
belongs_to :hole
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/kangaroo.rb | spec/support/models/kangaroo.rb | # frozen_string_literal: true
# rubocop:todo all
class Kangaroo
include Mongoid::Document
embeds_one :baby
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/order.rb | spec/support/models/order.rb | # frozen_string_literal: true
# rubocop:todo all
class Order
include Mongoid::Document
field :status, type: Mongoid::StringifiedSymbol
# This is a dummy field that verifies the Mongoid::Fields::StringifiedSymbol
# alias.
field :saved_status, type: StringifiedSymbol
embeds_many :purchased_items
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/cover.rb | spec/support/models/cover.rb | # frozen_string_literal: true
# rubocop:todo all
class Cover
include Mongoid::Document
include Mongoid::Timestamps
field :title, type: String
embedded_in :book
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/bomb.rb | spec/support/models/bomb.rb | # frozen_string_literal: true
# rubocop:todo all
class Bomb
include Mongoid::Document
has_one :explosion, dependent: :delete_all, autobuild: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/country_code.rb | spec/support/models/country_code.rb | # frozen_string_literal: true
# rubocop:todo all
class CountryCode
include Mongoid::Document
field :_id, type: Integer, overwrite: true, default: ->{ code }
field :code, type: Integer
field :iso, as: :iso_alpha2_code
embedded_in :phone_number, class_name: "Phone"
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/powerup.rb | spec/support/models/powerup.rb | # frozen_string_literal: true
# rubocop:todo all
class Powerup
include Mongoid::Document
field :name
belongs_to :player, inverse_of: :powerup
after_build do
self.name = "Quad Damage (#{player.frags})"
end
field :after_find_player
field :after_initialize_player
field :after_default_player, defau... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/page_question.rb | spec/support/models/page_question.rb | # frozen_string_literal: true
# rubocop:todo all
class PageQuestion
include Mongoid::Document
embedded_in :page
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/doctor.rb | spec/support/models/doctor.rb | # frozen_string_literal: true
# rubocop:todo all
class Doctor < Person
field :specialty, as: :spec
has_and_belongs_to_many :users, validate: false, inverse_of: nil
def specialty=(text)
users.push(User.new)
super
end
end
class Doktor < Person
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/purchased_item.rb | spec/support/models/purchased_item.rb | # frozen_string_literal: true
# rubocop:todo all
class PurchasedItem
include Mongoid::Document
field :item_id, type: Mongoid::StringifiedSymbol
validates_uniqueness_of :item_id
embedded_in :order
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/membership.rb | spec/support/models/membership.rb | # frozen_string_literal: true
# rubocop:todo all
class Membership
include Mongoid::Document
field :name, type: String
embedded_in :account
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/parent_doc.rb | spec/support/models/parent_doc.rb | # frozen_string_literal: true
# rubocop:todo all
class ParentDoc
include Mongoid::Document
field :statistic
field :children_order, type: Array, default: [] # hold all the children's id
embeds_many :children, class_name: 'ChildDoc', inverse_of: :parent_doc
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/my_hash.rb | spec/support/models/my_hash.rb | # frozen_string_literal: true
# rubocop:todo all
class MyHash < ::Hash
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/armrest.rb | spec/support/models/armrest.rb | # frozen_string_literal: true
# rubocop:todo all
class Armrest
include Mongoid::Document
embedded_in :seat
field :side
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/child.rb | spec/support/models/child.rb | # frozen_string_literal: true
# rubocop:todo all
class Child
include Mongoid::Document
embedded_in :parent, inverse_of: :childable, polymorphic: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/employer.rb | spec/support/models/employer.rb | # frozen_string_literal: true
# rubocop:todo all
class Employer
def id
"1"
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/ordered_preference.rb | spec/support/models/ordered_preference.rb | # frozen_string_literal: true
# rubocop:todo all
class OrderedPreference
include Mongoid::Document
field :name, type: String
field :value, type: String
has_and_belongs_to_many :people, validate: false
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/validation_callback.rb | spec/support/models/validation_callback.rb | # frozen_string_literal: true
# rubocop:todo all
class ValidationCallback
include Mongoid::Document
field :history, type: Array, default: []
validate do
self.history << :validate
end
before_validation { self.history << :before_validation }
after_validation { self.history << :after_validation }
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/tree.rb | spec/support/models/tree.rb | # frozen_string_literal: true
# rubocop:todo all
class Tree
include Mongoid::Document
field :name
field :evergreen, type: Mongoid::Boolean
scope :verdant, ->{ where(evergreen: true) }
default_scope ->{ asc(:name) }
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/customer.rb | spec/support/models/customer.rb | # frozen_string_literal: true
# rubocop:todo all
class Customer
include Mongoid::Document
field :name
embeds_one :home_address, class_name: 'CustomerAddress', as: :addressable
embeds_one :work_address, class_name: 'CustomerAddress', as: :addressable
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/shield.rb | spec/support/models/shield.rb | # frozen_string_literal: true
# rubocop:todo all
class Shield
include Mongoid::Document
has_and_belongs_to_many :players
field :after_find_player
field :after_initialize_player
field :after_default_player, default: ->{ players.first&._id }
after_find do |doc|
doc.after_find_player = players.first&._i... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/canvas.rb | spec/support/models/canvas.rb | # frozen_string_literal: true
# rubocop:todo all
class Canvas
include Mongoid::Document
field :name
embeds_many :shapes
embeds_one :writer
embeds_one :palette
field :foo, type: String, default: ->{ "original" }
has_many :comments, as: :commentable
accepts_nested_attributes_for :shapes
accepts_nest... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/quiz.rb | spec/support/models/quiz.rb | # frozen_string_literal: true
# rubocop:todo all
class Quiz
include Mongoid::Document
include Mongoid::Timestamps::Created
field :name, type: String
field :topic, type: String
embeds_many :pages
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/address_component.rb | spec/support/models/address_component.rb | # frozen_string_literal: true
# rubocop:todo all
class AddressComponent
include Mongoid::Document
field :street, type: String
embedded_in :person
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/updatable.rb | spec/support/models/updatable.rb | # frozen_string_literal: true
# rubocop:todo all
class Updatable
include Mongoid::Document
field :updated_at, type: BSON::Timestamp
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/piano.rb | spec/support/models/piano.rb | # frozen_string_literal: true
# rubocop:todo all
class Piano < Instrument
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/strategy.rb | spec/support/models/strategy.rb | # frozen_string_literal: true
# rubocop:todo all
class Strategy
include Mongoid::Document
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/eye_bowl.rb | spec/support/models/eye_bowl.rb | # frozen_string_literal: true
# rubocop:todo all
class EyeBowl
include Mongoid::Document
has_many :blue_eyes, class_name: "Eye", as: :eyeable
has_many :brown_eyes, class_name: "Eye", as: :eyeable
has_one :face, as: :suspended_in
has_one :eye, as: :suspended_in
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/store_as_dup_test1.rb | spec/support/models/store_as_dup_test1.rb | # frozen_string_literal: true
# rubocop:todo all
class StoreAsDupTest1
include Mongoid::Document
embeds_one :store_as_dup_test2, :store_as => :t
field :name
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/item.rb | spec/support/models/item.rb | # frozen_string_literal: true
# rubocop:todo all
class Item
include Mongoid::Document
field :title, type: String
field :is_rss, type: Mongoid::Boolean, default: false
field :user_login, type: String
end
require "support/models/sub_item"
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/account.rb | spec/support/models/account.rb | # frozen_string_literal: true
# rubocop:todo all
class Account
include Mongoid::Document
field :_id, type: String, overwrite: true, default: ->{ name.try(:parameterize) }
field :number, type: String
field :balance, type: Integer
field :nickname, type: String
field :name, type: String
field :balanced, t... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/firefox.rb | spec/support/models/firefox.rb | # frozen_string_literal: true
# rubocop:todo all
class Firefox < Browser
field :user_agent
def render; end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/title.rb | spec/support/models/title.rb | # frozen_string_literal: true
# rubocop:todo all
class Title
include Mongoid::Document
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/home.rb | spec/support/models/home.rb | # frozen_string_literal: true
# rubocop:todo all
class Home
include Mongoid::Document
belongs_to :person
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/game.rb | spec/support/models/game.rb | # frozen_string_literal: true
# rubocop:todo all
class Game
include Mongoid::Document
field :high_score, type: Integer, default: 500
field :score, type: Integer, default: 0
field :name
belongs_to :person, index: true, validate: true
belongs_to :parent, class_name: "Game", foreign_key: "parent-id"
has_o... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/idnodef.rb | spec/support/models/idnodef.rb | # frozen_string_literal: true
# rubocop:todo all
class Idnodef
include Mongoid::Document
field :_id, type: String, overwrite: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/dungeon.rb | spec/support/models/dungeon.rb | # frozen_string_literal: true
# rubocop:todo all
class Dungeon
include Mongoid::Document
has_and_belongs_to_many :dragons
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/symptom.rb | spec/support/models/symptom.rb | # frozen_string_literal: true
# rubocop:todo all
class Symptom
include Mongoid::Document
field :name, type: String
embedded_in :person
default_scope ->{ asc(:name) }
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/baby.rb | spec/support/models/baby.rb | # frozen_string_literal: true
# rubocop:todo all
class Baby
include Mongoid::Document
embedded_in :kangaroo
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/meat.rb | spec/support/models/meat.rb | # frozen_string_literal: true
# rubocop:todo all
class Meat
include Mongoid::Document
has_and_belongs_to_many :sandwiches
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/fanatic.rb | spec/support/models/fanatic.rb | # frozen_string_literal: true
# rubocop:todo all
class Fanatic
include Mongoid::Document
field :age, type: Integer
embedded_in :band
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/translation.rb | spec/support/models/translation.rb | # frozen_string_literal: true
# rubocop:todo all
class Translation
include Mongoid::Document
field :language
embedded_in :name
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/staff.rb | spec/support/models/staff.rb | # frozen_string_literal: true
# rubocop:todo all
class Staff
include Mongoid::Document
embedded_in :company
field :age, type: Integer
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/business.rb | spec/support/models/business.rb | # frozen_string_literal: true
# rubocop:todo all
class Business
include Mongoid::Document
field :name, type: String
has_and_belongs_to_many :owners, class_name: "User", validate: false
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/sound.rb | spec/support/models/sound.rb | # frozen_string_literal: true
# rubocop:todo all
class Sound
include Mongoid::Document
field :active, type: Mongoid::Boolean
default_scope ->{ where(active: true) }
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/driver.rb | spec/support/models/driver.rb | # frozen_string_literal: true
# rubocop:todo all
class Driver
include Mongoid::Document
has_one :vehicle
accepts_nested_attributes_for :vehicle
end
require "support/models/learner"
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/page.rb | spec/support/models/page.rb | # frozen_string_literal: true
# rubocop:todo all
class Page
include Mongoid::Document
embedded_in :quiz
embeds_many :page_questions
embedded_in :book, touch: true
embeds_many :notes
field :content, :type => String
after_initialize do
if self[:content]
self[:text] = self[:content]
self.r... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/building.rb | spec/support/models/building.rb | # frozen_string_literal: true
# rubocop:todo all
class Building
include Mongoid::Document
field :name, type: String
embeds_one :building_address, validate: false
embeds_many :contractors
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/implant.rb | spec/support/models/implant.rb | # frozen_string_literal: true
# rubocop:todo all
class Implant
include Mongoid::Document
field :name
field :impressions, type: Integer, default: 0
embedded_in :player, inverse_of: :implants
after_build do |doc|
doc.name = "Cochlear Implant (#{player.frags})"
end
field :after_find_player
field :... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/short_agent.rb | spec/support/models/short_agent.rb | # frozen_string_literal: true
# rubocop:todo all
class ShortAgent
include Mongoid::Document
include Mongoid::Timestamps::Updated::Short
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/browser.rb | spec/support/models/browser.rb | # frozen_string_literal: true
# rubocop:todo all
class Browser < Canvas
field :version, type: Integer
def render; end
end
require "support/models/firefox"
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/pet.rb | spec/support/models/pet.rb | # frozen_string_literal: true
# rubocop:todo all
class Pet
include Mongoid::Document
field :name
field :weight, type: Float, default: 0.0
embeds_many :vet_visits
embedded_in :pet_owner
after_destroy :set_destroy_flag
attr_writer :destroy_flag
def set_destroy_flag
@destroy_flag = true
end
def... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/node.rb | spec/support/models/node.rb | # frozen_string_literal: true
# rubocop:todo all
class Node
include Mongoid::Document
has_many :servers
accepts_nested_attributes_for :servers
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/exhibitor.rb | spec/support/models/exhibitor.rb | # frozen_string_literal: true
# rubocop:todo all
class Exhibitor
include Mongoid::Document
field :status, type: String
belongs_to :exhibition
has_and_belongs_to_many :artworks
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/fire_hydrant.rb | spec/support/models/fire_hydrant.rb | # frozen_string_literal: true
# rubocop:todo all
class FireHydrant
include Mongoid::Document
field :location, type: String
has_and_belongs_to_many :dogs, primary_key: :name
has_and_belongs_to_many :cats, primary_key: :name
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/pet_owner.rb | spec/support/models/pet_owner.rb | # frozen_string_literal: true
# rubocop:todo all
class PetOwner
include Mongoid::Document
field :title
embeds_one :pet, cascade_callbacks: true
embeds_one :address, as: :addressable
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/other_owner_object.rb | spec/support/models/other_owner_object.rb | # frozen_string_literal: true
# rubocop:todo all
class OtherOwnerObject
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/mop.rb | spec/support/models/mop.rb | # frozen_string_literal: true
# rubocop:todo all
# This class is used for embedded matcher testing.
class Mop
include Mongoid::Document
# The dynamic attributes are used so that the tests can use various
# field names as makes sense for the particular operator.
include Mongoid::Attributes::Dynamic
# We nee... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/description.rb | spec/support/models/description.rb | # frozen_string_literal: true
# rubocop:todo all
class Description
include Mongoid::Document
field :details
belongs_to :user
belongs_to :updater, class_name: 'User'
validates :user, associated: true
validates :details, presence: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/minim.rb | spec/support/models/minim.rb | # frozen_string_literal: true
# rubocop:todo all
# Minimal model, do not add any fields
class Minim
include Mongoid::Document
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/courier_job.rb | spec/support/models/courier_job.rb | # frozen_string_literal: true
# rubocop:todo all
class CourierJob
include Mongoid::Document
embeds_one :drop_address, as: :addressable, autobuild: true, class_name: "ShipmentAddress"
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.