Class: ActiveRecord::DatabaseConfigurations::HashConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_rls/database/configurations.rb

Instance Method Summary collapse

Constructor Details

#initialize(env_name, name, configuration_hash) ⇒ HashConfig

Returns a new instance of HashConfig.



9
10
11
12
13
# File 'lib/pg_rls/database/configurations.rb', line 9

def initialize(env_name, name, configuration_hash)
  @env_name = env_name
  @name = name
  @configuration_hash = configuration_hash
end

Instance Method Details

#admin_configuration_hashObject



21
22
23
# File 'lib/pg_rls/database/configurations.rb', line 21

def admin_configuration_hash
  @admin_configuration_hash ||= @configuration_hash
end

#configuration_hashObject



15
16
17
18
19
# File 'lib/pg_rls/database/configurations.rb', line 15

def configuration_hash
  return admin_configuration_hash if PgRls.as_db_admin?

  rls_configuration_hash
end

#rls_configuration_hashObject



25
26
27
28
29
30
# File 'lib/pg_rls/database/configurations.rb', line 25

def rls_configuration_hash
  @rls_configuration_hash ||= @configuration_hash.deep_dup.tap do |config|
    config[:username] = PgRls.username
    config[:password] = PgRls.password
  end.freeze
end