Sha256: 1edca9237b35a380c2585fea2bc5ca011fc184353876f4b7a7311e068ee9aeba

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-4.0.0.alpha1 spec/app/models/player.rb