Sha256: 611c99f943ce232c730599386c1759aad02efa9bd17167ee094ebc8972455ab8

Contents?: true

Size: 811 Bytes

Versions: 27

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true
# encoding: utf-8

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
      "extension"
    end
  end

  scope :inactive, ->{ where(active: false) }
  scope :frags_over, ->(count) { where(:frags.gt => count) }
  scope :deaths_under, ->(count) { where(:deaths.lt => count) }
  scope :deaths_over, ->(count) { where(:deaths.gt => count) }

  has_many :weapons
  has_one :powerup

  embeds_many :implants
  embeds_one :augmentation

  after_find do |doc|
    doc.impressions += 1
  end

  class << self
    def alive
      where(status: "Alive")
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mongoid-7.3.5 spec/support/models/player.rb
mongoid-7.3.4 spec/support/models/player.rb
mongoid-7.1.11 spec/app/models/player.rb
mongoid-7.2.6 spec/support/models/player.rb
mongoid-7.3.3 spec/support/models/player.rb
mongoid-7.3.2 spec/support/models/player.rb
mongoid-7.2.5 spec/support/models/player.rb
mongoid-7.1.10 spec/app/models/player.rb
mongoid-7.1.9 spec/app/models/player.rb
mongoid-7.2.4 spec/support/models/player.rb
mongoid-7.3.1 spec/support/models/player.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/spec/app/models/player.rb
mongoid-7.3.0 spec/support/models/player.rb
mongoid-7.2.3 spec/support/models/player.rb
mongoid-7.1.8 spec/app/models/player.rb
mongoid-7.2.2 spec/support/models/player.rb
mongoid-7.2.1 spec/support/models/player.rb
mongoid-7.1.7 spec/app/models/player.rb
mongoid-7.2.0 spec/support/models/player.rb
mongoid-7.1.6 spec/app/models/player.rb