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/models/division.rb | spec/support/models/division.rb | # frozen_string_literal: true
# rubocop:todo all
class Division
include Mongoid::Document
field :name, type: String
embedded_in :league
before_destroy :update_parent
def update_parent
league.name = "Destroyed"
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/word.rb | spec/support/models/word.rb | # frozen_string_literal: true
# rubocop:todo all
class Word
include Mongoid::Document
field :name, type: String
field :origin, type: String
belongs_to :dictionary
embeds_many :definitions, validate: false
embeds_many :word_origins, validate: false
embeds_one :pronunciation, validate: false
accepts_n... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/code.rb | spec/support/models/code.rb | # frozen_string_literal: true
# rubocop:todo all
class Code
include Mongoid::Document
field :name, type: String
embedded_in :address
embeds_one :deepest
end
class Deepest
include Mongoid::Document
embedded_in :code
field :array, 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/birthday.rb | spec/support/models/birthday.rb | # frozen_string_literal: true
# rubocop:todo all
class Birthday
include Mongoid::Document
field :title
field :date, type: Date
embedded_in :owner, inverse_of: :birthdays
def self.each_day(start_date, end_date)
groups = only(:date).asc(:date).where(:date.gte => start_date, :date.lte => end_date).group
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/registry.rb | spec/support/models/registry.rb | # frozen_string_literal: true
# rubocop:todo all
class Registry
include Mongoid::Document
field :data, type: BSON::Binary
field :obj_id, type: BSON::ObjectId
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_test3.rb | spec/support/models/store_as_dup_test3.rb | # frozen_string_literal: true
# rubocop:todo all
class StoreAsDupTest3
include Mongoid::Document
embeds_many :store_as_dup_test4s, :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/league.rb | spec/support/models/league.rb | # frozen_string_literal: true
# rubocop:todo all
class League
include Mongoid::Document
field :name, type: String
embeds_many :divisions
accepts_nested_attributes_for :divisions, allow_destroy: true
before_destroy :destroy_children
def destroy_children
divisions.destroy_all
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/owner.rb | spec/support/models/owner.rb | # frozen_string_literal: true
# rubocop:todo all
class Owner
include Mongoid::Document
field :name
has_many :events
embeds_many :birthdays
embeds_many :deeds
embeds_one :scribe
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/deed.rb | spec/support/models/deed.rb | # frozen_string_literal: true
# rubocop:todo all
class Deed
include Mongoid::Document
field :title, 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/scheduler.rb | spec/support/models/scheduler.rb | # frozen_string_literal: true
# rubocop:todo all
class Scheduler
include Mongoid::Document
def strategy
Strategy.new
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/animal.rb | spec/support/models/animal.rb | # frozen_string_literal: true
# rubocop:todo all
class Animal
include Mongoid::Document
field :_id, type: String, overwrite: true, default: ->{ name.try(:parameterize) }
field :name
field :height, type: Integer
field :weight, type: Integer
field :tags, type: Array
embedded_in :person
embedded_in :ci... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/category.rb | spec/support/models/category.rb | # frozen_string_literal: true
# rubocop:todo all
class Category
include Mongoid::Document
embedded_in :root_category
embedded_in :category
embeds_many :categories
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/track.rb | spec/support/models/track.rb | # frozen_string_literal: true
# rubocop:todo all
class Track
include Mongoid::Document
field :name, type: String
field :before_create_called, type: Mongoid::Boolean, default: false
field :before_save_called, type: Mongoid::Boolean, default: false
field :before_update_called, type: Mongoid::Boolean, default:... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/patient.rb | spec/support/models/patient.rb | # frozen_string_literal: true
# rubocop:todo all
class Patient
include Mongoid::Document
field :title, type: String
store_in collection: "inpatient"
embeds_many :addresses, as: :addressable
embeds_one :email
embeds_one :name, as: :namable
validates_presence_of :title, on: :create
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/shipping_pack.rb | spec/support/models/shipping_pack.rb | # frozen_string_literal: true
# rubocop:todo all
class ShippingPack < Pack
belongs_to :subscription, counter_cache: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/player.rb | spec/support/models/player.rb | # frozen_string_literal: true
# rubocop:todo all
class Player
include Mongoid::Document
field :active, type: Mongoid::Boolean
field :frags, type: Integer
field :deaths, type: Integer
field :impressions, type: Integer, default: 0
field :status
scope :active, ->{ where(active: true) } do
def extension... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/vet_visit.rb | spec/support/models/vet_visit.rb | # frozen_string_literal: true
# rubocop:todo all
class VetVisit
include Mongoid::Document
field :date, type: Date
embedded_in :pet
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/school.rb | spec/support/models/school.rb | # frozen_string_literal: true
# rubocop:todo all
class School
include Mongoid::Document
has_many :students
field :district, type: String
field :team, type: String
field :after_destroy_triggered, default: false
accepts_nested_attributes_for :students, allow_destroy: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/publication.rb | spec/support/models/publication.rb | # frozen_string_literal: true
# rubocop:todo all
require 'support/models/publication/encyclopedia'
require 'support/models/publication/review'
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/circle.rb | spec/support/models/circle.rb | # frozen_string_literal: true
# rubocop:todo all
class Circle < Shape
field :radius, type: Integer, default: 0
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/address.rb | spec/support/models/address.rb | # frozen_string_literal: true
# rubocop:todo all
class Address
include Mongoid::Document
field :_id, type: String, overwrite: true, default: ->{ street.try(:parameterize) }
attr_accessor :mode
field :address_type
field :number, type: Integer
field :no, type: Integer
field :h, as: :house, type: Integer... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/house.rb | spec/support/models/house.rb | # frozen_string_literal: true
# rubocop:todo all
class House
include Mongoid::Document
field :name, type: String
field :model, type: String
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/pack.rb | spec/support/models/pack.rb | # frozen_string_literal: true
# rubocop:todo all
class Pack
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/slave.rb | spec/support/models/slave.rb | # frozen_string_literal: true
# rubocop:todo all
class Slave
include Mongoid::Document
field :first_name
field :last_name
embeds_many :address_numbers
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/folder_item.rb | spec/support/models/folder_item.rb | # frozen_string_literal: true
# rubocop:todo all
class FolderItem
include Mongoid::Document
belongs_to :folder
field :name, type: String
validates :name, uniqueness: {scope: :folder_id}
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/square.rb | spec/support/models/square.rb | # frozen_string_literal: true
# rubocop:todo all
class Square < Shape
field :width, type: Integer, default: 0
field :height, type: Integer, default: 0
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/fish.rb | spec/support/models/fish.rb | # frozen_string_literal: true
# rubocop:todo all
class Fish
include Mongoid::Document
def self.fresh
where(fresh: true)
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/login.rb | spec/support/models/login.rb | # frozen_string_literal: true
# rubocop:todo all
class Login
include Mongoid::Document
field :_id, type: String, overwrite: true, default: ->{ username }
field :username, type: String
field :application_id, 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/word_origin.rb | spec/support/models/word_origin.rb | # frozen_string_literal: true
# rubocop:todo all
class WordOrigin
include Mongoid::Document
field :_id, type: Integer, overwrite: true, default: ->{ origin_id }
field :origin_id, type: Integer
field :country, type: String
field :city, 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/catalog.rb | spec/support/models/catalog.rb | # frozen_string_literal: true
# rubocop:todo all
class Catalog
include Mongoid::Document
field :array_field, type: Array
field :big_decimal_field, type: BigDecimal
field :boolean_field, type: Boolean
field :date_field, type: Date
field :date_time_field, type: DateTime
field :float_field, type: Float
f... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/article.rb | spec/support/models/article.rb | # frozen_string_literal: true
# rubocop:todo all
class Article
include Mongoid::Document
field :author_id, type: Integer
field :public, type: Mongoid::Boolean
field :title, type: String
field :is_rss, type: Mongoid::Boolean, default: false
field :user_login, type: String
has_and_belongs_to_many :tags, ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/line_item.rb | spec/support/models/line_item.rb | # frozen_string_literal: true
# rubocop:todo all
class LineItem
include Mongoid::Document
embedded_in :purchase
belongs_to :product, polymorphic: true
validates :product, presence: true, uniqueness: { scope: :product }
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/crate.rb | spec/support/models/crate.rb | # frozen_string_literal: true
# rubocop:todo all
class Crate
include Mongoid::Document
embedded_in :vehicle
embeds_many :toys
accepts_nested_attributes_for :toys
field :volume
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/location.rb | spec/support/models/location.rb | # frozen_string_literal: true
# rubocop:todo all
class Location
include Mongoid::Document
field :name
field :info, type: Hash
field :occupants, type: Array
field :number, type: Integer
embedded_in :address
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/email.rb | spec/support/models/email.rb | # frozen_string_literal: true
# rubocop:todo all
class Email
include Mongoid::Document
field :address
validates_uniqueness_of :address
embedded_in :patient
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/shape.rb | spec/support/models/shape.rb | # frozen_string_literal: true
# rubocop:todo all
class Shape
include Mongoid::Document
field :x, type: Integer, default: 0
field :y, type: Integer, default: 0
embedded_in :canvas
def render; end
end
require "support/models/circle"
require "support/models/square"
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/movie.rb | spec/support/models/movie.rb | # frozen_string_literal: true
# rubocop:todo all
class Movie
include Mongoid::Document
include Mongoid::Attributes::Dynamic
field :title, type: String
field :poster, type: Image
field :poster_thumb, type: Thumbnail
has_many :ratings, as: :ratable, dependent: :nullify
has_many :comments
def global_set
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/author.rb | spec/support/models/author.rb | # frozen_string_literal: true
# rubocop:todo all
class Author
include Mongoid::Document
field :id, type: Integer
field :author, type: Mongoid::Boolean
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/audible_sound.rb | spec/support/models/audible_sound.rb | # frozen_string_literal: true
# rubocop:todo all
class AudibleSound < Sound; end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/manufacturer.rb | spec/support/models/manufacturer.rb | # frozen_string_literal: true
# rubocop:todo all
class Manufacturer
include Mongoid::Document
field :products, type: Array, default: []
validates_presence_of :products
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/instrument.rb | spec/support/models/instrument.rb | # frozen_string_literal: true
# rubocop:todo all
class Instrument
include Mongoid::Document
end
require "support/models/guitar"
require "support/models/piano"
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/comment.rb | spec/support/models/comment.rb | # frozen_string_literal: true
# rubocop:todo all
class Comment
include Mongoid::Document
field :title, type: String
field :text, type: String
belongs_to :account
belongs_to :movie
belongs_to :rating
belongs_to :wiki_page
belongs_to :commentable, polymorphic: true
validates :title, presence: true
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/pencil.rb | spec/support/models/pencil.rb | # frozen_string_literal: true
# rubocop:todo all
class Pencil < Tool; end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/writer.rb | spec/support/models/writer.rb | # frozen_string_literal: true
# rubocop:todo all
class Writer
include Mongoid::Document
field :speed, type: Integer, default: 0
embedded_in :canvas
def write; end
end
require "support/models/pdf_writer"
require "support/models/html_writer"
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/video_game.rb | spec/support/models/video_game.rb | # frozen_string_literal: true
# rubocop:todo all
class VideoGame < Game; end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/face.rb | spec/support/models/face.rb | # frozen_string_literal: true
# rubocop:todo all
class Face
include Mongoid::Document
has_one :left_eye, class_name: "Eye", as: :eyeable
has_one :right_eye, class_name: "Eye", as: :eyeable
belongs_to :suspended_in, 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/name.rb | spec/support/models/name.rb | # frozen_string_literal: true
# rubocop:todo all
class Name
include Mongoid::Document
include Mongoid::Attributes::Dynamic
validate :is_not_jamis
field :_id, type: String, overwrite: true, default: ->{
"#{first_name}-#{last_name}"
}
field :first_name, type: String
field :last_name, type: String
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/message.rb | spec/support/models/message.rb | # frozen_string_literal: true
# rubocop:todo all
class Message
include Mongoid::Document
field :body, type: String
field :priority, type: Integer
embedded_in :person
has_and_belongs_to_many :receivers, class_name: "Person", inverse_of: nil
has_one :post, as: :posteable
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/coding.rb | spec/support/models/coding.rb | # frozen_string_literal: true
# rubocop:todo all
require 'support/models/coding/pull_request'
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/passport.rb | spec/support/models/passport.rb | # frozen_string_literal: true
# rubocop:todo all
class Passport
include Mongoid::Document
field :number, type: String
field :country, type: String
field :exp, as: :expiration_date, type: Date
field :name, localize: true
field :bp, as: :birthplace, localize: true
field :localized_translations, localize: ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/callback_test.rb | spec/support/models/callback_test.rb | # frozen_string_literal: true
# rubocop:todo all
class CallbackTest
include Mongoid::Document
around_save :execute
def execute
yield(self)
true
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/basic.rb | spec/support/models/basic.rb | # frozen_string_literal: true
# rubocop:todo all
class Basic
include Mongoid::Document
end
class SubBasic < Basic
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/appointment.rb | spec/support/models/appointment.rb | # frozen_string_literal: true
# rubocop:todo all
class Appointment
include Mongoid::Document
field :active, type: Mongoid::Boolean, default: true
field :timed, type: Mongoid::Boolean, default: true
embedded_in :person
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/washer.rb | spec/support/models/washer.rb | # frozen_string_literal: true
# rubocop:todo all
class Washer
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/actress.rb | spec/support/models/actress.rb | # frozen_string_literal: true
# rubocop:todo all
class Actress < Actor
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/root_category.rb | spec/support/models/root_category.rb | # frozen_string_literal: true
# rubocop:todo all
class RootCategory
include Mongoid::Document
embeds_many :categories
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/actor.rb | spec/support/models/actor.rb | # frozen_string_literal: true
# rubocop:todo all
class Actor
include Mongoid::Document
field :name
field :after_custom_count, type: Integer, default: 0
has_and_belongs_to_many :tags
embeds_many :things, validate: false, cascade_callbacks: true
accepts_nested_attributes_for :things, allow_destroy: true
d... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/note.rb | spec/support/models/note.rb | # frozen_string_literal: true
# rubocop:todo all
class Note
include Mongoid::Document
field :text, type: String
field :saved, type: Mongoid::Boolean, default: false
embedded_in :noteable, polymorphic: true
after_save :update_saved
scope :permanent, ->{ where(saved: true) }
def update_saved
self.sa... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/override.rb | spec/support/models/override.rb | # frozen_string_literal: true
# rubocop:todo all
class Override
include Mongoid::Document
def self.public_method
end
protected
def self.protected_method
end
private
def self.private_method
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/bolt.rb | spec/support/models/bolt.rb | # frozen_string_literal: true
# rubocop:todo all
class Bolt
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/store_as_dup_test4.rb | spec/support/models/store_as_dup_test4.rb | # frozen_string_literal: true
# rubocop:todo all
class StoreAsDupTest4
include Mongoid::Document
embedded_in :store_as_dup_test3
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/rating.rb | spec/support/models/rating.rb | # frozen_string_literal: true
# rubocop:todo all
class Rating
include Mongoid::Document
field :value, type: Integer
belongs_to :ratable, polymorphic: true
has_many :comments
validates_numericality_of :value, less_than: 100, allow_nil: true
validates :ratable, associated: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/explosion.rb | spec/support/models/explosion.rb | # frozen_string_literal: true
# rubocop:todo all
class Explosion
include Mongoid::Document
belongs_to :bomb
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/sub_item.rb | spec/support/models/sub_item.rb | # frozen_string_literal: true
# rubocop:todo all
class SubItem < Item
embedded_in :parent
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/pub.rb | spec/support/models/pub.rb | # frozen_string_literal: true
# rubocop:todo all
class Pub
include Mongoid::Document
include Mongoid::Attributes::Dynamic
field :location, type: Array
index location: "2dsphere"
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/favorite.rb | spec/support/models/favorite.rb | # frozen_string_literal: true
# rubocop:todo all
class Favorite
include Mongoid::Document
field :title
validates_uniqueness_of :title, case_sensitive: false
# See MONGOID-5016. The default for `touch` is now `true` for embedded_in
# associations, which causes the referenced class to be loaded eagerly so
#... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/dictionary.rb | spec/support/models/dictionary.rb | # frozen_string_literal: true
# rubocop:todo all
class Dictionary
include Mongoid::Document
field :name, type: String
field :publisher, type: String
field :year, type: Integer
# This field must be a Time
field :published, type: Time
# This field must be a Date
field :submitted_on, type: Date
field... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/post.rb | spec/support/models/post.rb | # frozen_string_literal: true
# rubocop:todo all
class Post
include Mongoid::Document
include Mongoid::Attributes::Dynamic
field :title, type: String
field :content, type: String
field :rating, type: Integer
field :person_title, type: String, default: ->{ person.title if ivar(:person) }
attr_accessor :... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/pizza.rb | spec/support/models/pizza.rb | # frozen_string_literal: true
# rubocop:todo all
class Pizza
include Mongoid::Document
field :name, type: String
has_one :topping, autosave: true
validates_presence_of :topping
accepts_nested_attributes_for :topping
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/thing.rb | spec/support/models/thing.rb | # frozen_string_literal: true
# rubocop:todo all
class Thing
include Mongoid::Document
before_destroy :dont_do_it
embedded_in :actor
def dont_do_it
throw(:abort)
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/car.rb | spec/support/models/car.rb | # frozen_string_literal: true
# rubocop:todo all
class Car < Vehicle; end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/post_genre.rb | spec/support/models/post_genre.rb | # frozen_string_literal: true
# rubocop:todo all
class PostGenre
include Mongoid::Document
field :posts_count, type: Integer, default: 0
has_many :posts, inverse_of: :genre
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/bar.rb | spec/support/models/bar.rb | # frozen_string_literal: true
# rubocop:todo all
class Bar
include Mongoid::Document
include Mongoid::Attributes::Dynamic
field :name, type: String
field :location, type: Array
field :lat_lng, type: LatLng
has_one :rating, as: :ratable
index location: "2d"
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/palette.rb | spec/support/models/palette.rb | # frozen_string_literal: true
# rubocop:todo all
class Palette
include Mongoid::Document
embedded_in :canvas
embeds_many :tools
end
require "support/models/big_palette"
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/shipping_container.rb | spec/support/models/shipping_container.rb | # frozen_string_literal: true
# rubocop:todo all
class ShippingContainer
include Mongoid::Document
has_many :vehicles
accepts_nested_attributes_for :vehicles
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/product.rb | spec/support/models/product.rb | # frozen_string_literal: true
# rubocop:todo all
class Product
include Mongoid::Document
field :description, localize: true
field :name, localize: true, default: "no translation"
field :price, type: Integer
field :brand_name
field :stores, type: Array
field :website, localize: true
field :sku, as: :sto... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/church.rb | spec/support/models/church.rb | # frozen_string_literal: true
# rubocop:todo all
class Church
include Mongoid::Document
has_many :acolytes, validate: false
field :location, type: Hash
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/definition.rb | spec/support/models/definition.rb | # frozen_string_literal: true
# rubocop:todo all
class Definition
include Mongoid::Document
field :description, type: String
field :p, as: :part, type: String
field :regular, type: Mongoid::Boolean
field :syn, as: :synonyms, localize: true, type: String
field :active, type: Mongoid::Boolean, localize: true... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/parent.rb | spec/support/models/parent.rb | # frozen_string_literal: true
# rubocop:todo all
class Parent
include Mongoid::Document
embeds_many :sub_items
embeds_one :first_child, class_name: "Child", as: :childable
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/ownable.rb | spec/support/models/ownable.rb | # frozen_string_literal: true
# rubocop:todo all
module Ownable
extend ActiveSupport::Concern
included do
belongs_to :user
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/template.rb | spec/support/models/template.rb | # frozen_string_literal: true
# rubocop:todo all
class Template
include Mongoid::Document
field :active, type: Mongoid::Boolean, default: false
validates :active, 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/sandwich.rb | spec/support/models/sandwich.rb | # frozen_string_literal: true
# rubocop:todo all
class Sandwich
include Mongoid::Document
has_and_belongs_to_many :meats
field :name, type: String
belongs_to :posteable, polymorphic: true
accepts_nested_attributes_for :posteable, autosave: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/purchase.rb | spec/support/models/purchase.rb | # frozen_string_literal: true
# rubocop:todo all
class Purchase
include Mongoid::Document
embeds_many :line_items
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/dog.rb | spec/support/models/dog.rb | # frozen_string_literal: true
# rubocop:todo all
class Dog
include Mongoid::Document
field :name, type: String
has_and_belongs_to_many :breeds
has_and_belongs_to_many :fire_hydrants, primary_key: :location
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/simple.rb | spec/support/models/simple.rb | # frozen_string_literal: true
# rubocop:todo all
class Simple
include Mongoid::Document
field :name, type: String
scope :nothing, -> { none }
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/oscar.rb | spec/support/models/oscar.rb | # frozen_string_literal: true
# rubocop:todo all
class Oscar
include Mongoid::Document
field :title, type: String
field :destroy_after_save, type: Mongoid::Boolean, default: false
before_save :complain
def complain
if destroy_after_save?
destroy
else
throw(:abort)
end
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/guitar.rb | spec/support/models/guitar.rb | # frozen_string_literal: true
# rubocop:todo all
class Guitar < Instrument
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/dragon.rb | spec/support/models/dragon.rb | # frozen_string_literal: true
# rubocop:todo all
class Dragon
include Mongoid::Document
has_and_belongs_to_many :dungeons
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/system_role.rb | spec/support/models/system_role.rb | # rubocop:todo all
class SystemRole
include Mongoid::Document
# NOTE: this model is for test purposes only. It is not recommended that you
# store Mongoid documents in system collections.
store_in collection: "system.roles", database: "admin"
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/video.rb | spec/support/models/video.rb | # frozen_string_literal: true
# rubocop:todo all
class Video
include Mongoid::Document
field :title, type: String
field :year, type: Integer
field :release_dates, type: Set
field :genres, type: Array
embedded_in :person
belongs_to :post
belongs_to :game
default_scope ->{ asc(:title) }
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/folder.rb | spec/support/models/folder.rb | # frozen_string_literal: true
# rubocop:todo all
class Folder
include Mongoid::Document
field :name, type: String
has_many :folder_items
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/question.rb | spec/support/models/question.rb | # frozen_string_literal: true
# rubocop:todo all
class Question
include Mongoid::Document
field :content
embedded_in :survey
embeds_many :answers
accepts_nested_attributes_for :answers, reject_if: ->(a){ a[:content].blank? }, allow_destroy: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/odd.rb | spec/support/models/odd.rb | # frozen_string_literal: true
# rubocop:todo all
class Odd
include Mongoid::Document
field :name
belongs_to :parent, class_name: 'Even', inverse_of: :odds
has_many :evens, inverse_of: :parent
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/user_account.rb | spec/support/models/user_account.rb | # frozen_string_literal: true
# rubocop:todo all
class UserAccount
include Mongoid::Document
field :username, type: String
field :name, type: String
field :email, type: String
validates_uniqueness_of :username, message: "is not unique"
validates_uniqueness_of :email, message: "is not unique", case_sensitiv... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/band.rb | spec/support/models/band.rb | # frozen_string_literal: true
# rubocop:todo all
class Band
include Mongoid::Document
include Mongoid::Attributes::Dynamic
field :name, type: String
field :active, type: Mongoid::Boolean, default: true
field :origin, type: String
field :genres, type: Array
field :member_count, type: Integer
field :mem... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/draft.rb | spec/support/models/draft.rb | # frozen_string_literal: true
# rubocop:todo all
class Draft
include Mongoid::Document
field :text
recursively_embeds_one
index text: 1
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/acolyte.rb | spec/support/models/acolyte.rb | # frozen_string_literal: true
# rubocop:todo all
class Acolyte
include Mongoid::Document
include Mongoid::Attributes::Dynamic
field :status
field :name
embeds_many :versions, as: :memorable
belongs_to :church
default_scope ->{ asc(:name) }
scope :active, ->{ where(status: "active") }
scope :named, ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/name_only.rb | spec/support/models/name_only.rb | # frozen_string_literal: true
# rubocop:todo all
# Model with one field called name
class NameOnly
include Mongoid::Document
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/customer_address.rb | spec/support/models/customer_address.rb | # frozen_string_literal: true
# rubocop:todo all
class CustomerAddress
include Mongoid::Document
field :street, type: String
field :city, type: String
field :state, type: String
embedded_in :addressable, 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/drug.rb | spec/support/models/drug.rb | # frozen_string_literal: true
# rubocop:todo all
class Drug
include Mongoid::Document
field :name, type: String
field :generic, type: Mongoid::Boolean
belongs_to :person, counter_cache: true
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.