Sha256: 2f9b35cf3d7a60b47b2a0accac25ccd6a5c071e737c1b8e1f48e87a59cc490e2

Contents?: true

Size: 741 Bytes

Versions: 14

Compression:

Stored size: 741 Bytes

Contents

class Player
  include Mongoid::Document
  field :active, type: 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

14 entries across 14 versions & 6 rubygems

Version Path
mongoid-3.1.7 spec/app/models/player.rb
mongoid-3.1.6 spec/app/models/player.rb
sepastian-mongoid-rails4-4.0.1.alpha spec/app/models/player.rb
sepastian-mongoid-rails4-4.0.0.alpha spec/app/models/player.rb
mongoid-3.1.5 spec/app/models/player.rb
mongoid_heroku_stable-4.0.0 spec/app/models/player.rb
mongoid_rails4-4.0.0 spec/app/models/player.rb
mongoid-paranoia-0.3.0 spec/app/models/player.rb
mongoid-paranoia-0.2.1 spec/app/models/player.rb
mongoid-versioning-0.2.0 spec/app/models/player.rb
mongoid-paranoia-0.2.0 spec/app/models/player.rb
mongoid-paranoia-0.1.1 spec/app/models/player.rb
mongoid-versioning-0.1.0 spec/app/models/player.rb
mongoid-paranoia-0.1.0 spec/app/models/player.rb