Sha256: cc0a53568e1713d72b8be373d6282653039b0a6e6cdcdbf637dd7c8edc88e49e

Contents?: true

Size: 791 Bytes

Versions: 13

Compression:

Stored size: 791 Bytes

Contents

class Account
  include Mongoid::Document

  field :_id, type: String, overwrite: true, default: ->{ name.try(:parameterize) }

  field :number, type: String
  field :balance, type: String
  field :nickname, type: String
  field :name, type: String
  field :balanced, type: Mongoid::Boolean, default: ->{ balance? ? true : false }

  field :overridden, type: String

  embeds_many :memberships
  belongs_to :creator, class_name: "User", foreign_key: :creator_id
  belongs_to :person
  has_many :alerts, autosave: false
  has_and_belongs_to_many :agents
  has_one :comment, validate: false

  validates_presence_of :name
  validates_presence_of :nickname, on: :upsert
  validates_length_of :name, maximum: 10, on: :create

  def overridden
    self[:overridden] = "not recommended"
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-4.0.2/spec/app/models/account.rb
mongoid-5.0.0 spec/app/models/account.rb
mongoid-5.0.0.rc0 spec/app/models/account.rb
mongoid-5.0.0.beta spec/app/models/account.rb
mongoid-4.0.2 spec/app/models/account.rb
mongoid-4.0.1 spec/app/models/account.rb
mongoid-4.0.0 spec/app/models/account.rb
mongoid-4.0.0.rc2 spec/app/models/account.rb
mongoid-4.0.0.rc1 spec/app/models/account.rb
mongoid-4.0.0.beta2 spec/app/models/account.rb
mongoid-4.0.0.beta1 spec/app/models/account.rb
mongoid-4.0.0.alpha2 spec/app/models/account.rb
mongoid-4.0.0.alpha1 spec/app/models/account.rb