Skip to content

Commit

Permalink
Support global_records_identifier configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
marshluca committed Jan 10, 2024
1 parent 8e8f9de commit 217ef99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/acts_as_tenant/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ActsAsTenant
class Configuration
attr_writer :require_tenant, :pkey
attr_writer :require_tenant, :pkey, :global_records_identifier

def require_tenant
@require_tenant ||= false
Expand All @@ -10,6 +10,10 @@ def pkey
@pkey ||= :id
end

def global_records_identifier
@global_records_identifier ||= nil
end

def job_scope
@job_scope || ->(relation) { relation.all }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/acts_as_tenant/model_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def acts_as_tenant(tenant = :account, scope = nil, **options)

if ActsAsTenant.current_tenant
keys = [ActsAsTenant.current_tenant.send(pkey)].compact
keys.push(nil) if options[:has_global_records]
keys.push(ActsAsTenant.global_records_identifier) if options[:has_global_records]

if options[:through]
query_criteria = {options[:through] => {fkey.to_sym => keys}}
Expand Down

0 comments on commit 217ef99

Please sign in to comment.