Module: TenantUtils

Defined in:
lib/utils/tenants.rb

Class Method Summary collapse

Class Method Details

.extract_tenant_field(tenants, dashboard_owner) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/utils/tenants.rb', line 12

def self.extract_tenant_field(tenants, dashboard_owner)
  if tenants[0].is_a?(String) || tenants[0].is_a?(Numeric)
    dashboard_owner
  elsif tenants[0].is_a?(Hash) && tenants[0].key?('tenant_field')
    tenants[0]['tenant_field']
  else
    raise 'Invalid format for tenants'
  end
end

.extract_tenant_ids(tenants) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/utils/tenants.rb', line 2

def self.extract_tenant_ids(tenants)
  if tenants[0].is_a?(String) || tenants[0].is_a?(Numeric)
    tenants
  elsif tenants[0].is_a?(Hash) && tenants[0].key?('tenant_ids')
    tenants[0]['tenant_ids']
  else
    raise 'Invalid format for tenants'
  end
end