Sha256: 66926388e0568b7205ba5aeab62daab4cec3233aa33b516251d3c102c31279b5

Contents?: true

Size: 412 Bytes

Versions: 1

Compression:

Stored size: 412 Bytes

Contents

module Mongoid
  module Tenancy
    extend ActiveSupport::Concern

    included do
      field :uri,     type: String

      validates :uri, uniqueness: true

      index({ uri: 1 }, unique: true)

      def self.tenants
        all.each do |t|
          t.tenancy!
          yield t
        end
      end
    end

    def tenancy!
      Thread.current[:mongodb] = _id.to_s
    end
  end # Tenancy
end # Mongoid

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-tenant-0.0.5 lib/mongoid/tenancy.rb