Class: TenantLevelSecurity::SchemaDumper::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord-tenant-level-security/schema_dumper.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_name:, partition_key:) ⇒ Policy

Returns a new instance of Policy.



51
52
53
54
# File 'lib/activerecord-tenant-level-security/schema_dumper.rb', line 51

def initialize(table_name:, partition_key:)
  @table_name = table_name
  @partition_key = partition_key
end

Instance Method Details

#to_schemaObject



56
57
58
59
60
61
62
# File 'lib/activerecord-tenant-level-security/schema_dumper.rb', line 56

def to_schema
  schema = %(  create_policy "#{table_name}")
  if partition_key != TenantLevelSecurity::DEFAULT_PARTITION_KEY
    schema += %(, partition_key: "#{partition_key}")
  end
  schema
end