Module: ActiveRecord::Tenanted::TenantCommon
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_record/tenanted/tenant.rb
Overview
instance methods common to both Tenant and Subtenant
Instance Method Summary collapse
- #association(name) ⇒ Object
- #cache_key ⇒ Object
- #inspect ⇒ Object
- #to_global_id(options = {}) ⇒ Object (also: #to_gid)
- #to_signed_global_id(options = {}) ⇒ Object (also: #to_sgid)
Instance Method Details
#association(name) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/active_record/tenanted/tenant.rb', line 33 def association(name) super.tap do |assoc| if assoc.reflection.polymorphic? || assoc.reflection.klass.tenanted? ensure_tenant_context_safety end end end |
#cache_key ⇒ Object
15 16 17 |
# File 'lib/active_record/tenanted/tenant.rb', line 15 def cache_key tenant ? "#{tenant}/#{super}" : super end |
#inspect ⇒ Object
19 20 21 22 23 |
# File 'lib/active_record/tenanted/tenant.rb', line 19 def inspect return super unless tenant super.sub(/\A#<\S+ /, "\\0tenant: #{tenant.inspect}, ") end |
#to_global_id(options = {}) ⇒ Object Also known as: to_gid
25 26 27 |
# File 'lib/active_record/tenanted/tenant.rb', line 25 def to_global_id( = {}) super(.merge(tenant: tenant)) end |
#to_signed_global_id(options = {}) ⇒ Object Also known as: to_sgid
29 30 31 |
# File 'lib/active_record/tenanted/tenant.rb', line 29 def to_signed_global_id( = {}) super(.merge(tenant: tenant)) end |