Sha256: 783fc41aceb28dd1f279417096781c95bbbaf152dfbf9dd49ef4f25121933458

Contents?: true

Size: 638 Bytes

Versions: 20

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

class Name
  include Mongoid::Document
  include Mongoid::Attributes::Dynamic

  field :_id, type: String, overwrite: true, default: ->{
    "#{first_name}-#{last_name}"
  }

  field :first_name, type: String
  field :last_name, type: String
  field :parent_title, type: String
  field :middle, type: String

  embeds_many :translations, validate: false
  embeds_one :language, as: :translatable, validate: false
  embedded_in :namable, polymorphic: true
  embedded_in :person

  accepts_nested_attributes_for :language

  def set_parent=(set = false)
    self.parent_title = namable.title if set
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mongoid-8.1.4 spec/support/models/name.rb
mongoid-8.0.7 spec/support/models/name.rb
mongoid-8.1.3 spec/support/models/name.rb
mongoid-8.1.2 spec/support/models/name.rb
mongoid-8.0.6 spec/support/models/name.rb
mongoid-7.5.4 spec/support/models/name.rb
mongoid-8.1.1 spec/support/models/name.rb
mongoid-8.0.5 spec/support/models/name.rb
mongoid-8.1.0 spec/support/models/name.rb
mongoid-7.5.3 spec/support/models/name.rb
mongoid-8.0.4 spec/support/models/name.rb
mongoid-8.0.3 spec/support/models/name.rb
mongoid-7.5.2 spec/support/models/name.rb
mongoid-8.0.2 spec/support/models/name.rb
mongoid-7.5.1 spec/support/models/name.rb
mongoid-7.4.3 spec/support/models/name.rb
mongoid-8.0.1 spec/support/models/name.rb
mongoid-7.5.0 spec/support/models/name.rb
mongoid-7.4.1 spec/support/models/name.rb
mongoid-7.4.0 spec/support/models/name.rb