Module: ActiveTenant::ActiveRecord::Base
- Defined in:
- lib/active_tenant/active_record_extensions.rb
Instance Method Summary collapse
- #all_tenants ⇒ Object
- #belongs_to_tenant_global ⇒ Object
- #create_tenant(name) ⇒ Object
- #remove_tenant(name) ⇒ Object
- #tenant? ⇒ Boolean
- #tenant_name ⇒ Object
- #with_tenant(name) ⇒ Object
Instance Method Details
#all_tenants ⇒ Object
5 6 7 |
# File 'lib/active_tenant/active_record_extensions.rb', line 5 def all_tenants ActiveTenant.current.all end |
#belongs_to_tenant_global ⇒ Object
29 30 31 |
# File 'lib/active_tenant/active_record_extensions.rb', line 29 def belongs_to_tenant_global establish_connection ActiveTenant.current.connection_settings(ActiveTenant.current.global) end |
#create_tenant(name) ⇒ Object
9 10 11 |
# File 'lib/active_tenant/active_record_extensions.rb', line 9 def create_tenant(name) ActiveTenant.current.create name end |
#remove_tenant(name) ⇒ Object
13 14 15 |
# File 'lib/active_tenant/active_record_extensions.rb', line 13 def remove_tenant(name) ActiveTenant.current.remove name end |
#tenant? ⇒ Boolean
21 22 23 |
# File 'lib/active_tenant/active_record_extensions.rb', line 21 def tenant? !ActiveTenant.current.global? end |
#tenant_name ⇒ Object
25 26 27 |
# File 'lib/active_tenant/active_record_extensions.rb', line 25 def tenant_name ActiveTenant.current.name if tenant? end |
#with_tenant(name) ⇒ Object
17 18 19 |
# File 'lib/active_tenant/active_record_extensions.rb', line 17 def with_tenant(name) ActiveTenant.current.with(name) { yield } end |