Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (17 sloc) 348 Bytes
class Tenant < ActiveRecord::Base
class << self
def current
Thread.current[:tenant]
end
def current=(tenant)
Thread.current[:tenant] = tenant
end
end
validates :name, :host, presence: true
def with
previous, Tenant.current = Tenant.current, self
yield
ensure
Tenant.current = previous
end
end