Sha256: 9fa7ca463b950e3a26a23eaf85b42b867a75ed081305155bc2ede94f4ac443a7

Contents?: true

Size: 765 Bytes

Versions: 9

Compression:

Stored size: 765 Bytes

Contents

class AsyncAction
  include Mongoid::Document

  field :player_id, type: Moped::BSON::ObjectId
  field :action_id , type: Object
  field :request_url, type: String
  field :request    # anything
  field :response   # anything, can be null
  field :attempts, type: Integer, default: 0

  index({ player_id: 1, action_id: 1 }, { unique: true })

  validates_presence_of :player_id
  validates_presence_of :action_id
  validates_presence_of :request_url
  validates_presence_of :request
  validates_uniqueness_of :action_id, scope: :player_id

  Player # in order to find with ActiveSupport::Dependency
  if defined? ::Player
    belongs_to :player # for Rails Admin
    class ::Player; has_many :async_actions end
  else
    raise "Player class not found!"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
libgss-0.11.0 spec/support/models/async_action.rb
libgss-0.10.0 spec/support/models/async_action.rb
libgss-0.9.0 spec/support/models/async_action.rb
libgss-0.8.4 spec/support/models/async_action.rb
libgss-0.8.3 spec/support/models/async_action.rb
libgss-0.8.2 spec/support/models/async_action.rb
libgss-0.8.1 spec/support/models/async_action.rb
libgss-0.8.0 spec/support/models/async_action.rb
libgss-0.7.6 spec/support/models/async_action.rb