Class: MultiTenantSupport::FindTenantAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_tenant_support/find_tenant_account.rb

Class Method Summary collapse

Class Method Details

.call(subdomains:, domain:) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/multi_tenant_support/find_tenant_account.rb', line 5

def call(subdomains:, domain:)
  subdomain = subdomains.select do |subdomain|
    excluded_subdomains.none? do |excluded_subdomain|
      excluded_subdomain.to_s.downcase == subdomain.to_s.downcase
    end
  end.last.presence

  subdomain ? find_by(subdomain: subdomain) : find_by(domain: domain)
end