Class: Role
- Inherits:
-
Object
- Object
- Role
- Defined in:
- lib/role.rb
Constant Summary collapse
- ADMIN_ROLE =
'admin'.freeze
- USERNAME_POSTFIX =
"_#{AnalyticDBConnectionFactory::DB_TYPE}_USERNAME".upcase.freeze
- PASSWORD_POSTFIX =
"_#{AnalyticDBConnectionFactory::DB_TYPE}_PASSWORD".upcase.freeze
Class Method Summary collapse
- .configured_connections ⇒ Object
- .determine_configured_connections ⇒ Object
- .name_to_password_key(name) ⇒ Object
- .name_to_username_key(name) ⇒ Object
- .password_key_to_name(key) ⇒ Object
- .username_key_to_name(key) ⇒ Object
Class Method Details
.configured_connections ⇒ Object
24 25 26 |
# File 'lib/role.rb', line 24 def configured_connections @configured_connections ||= determine_configured_connections end |
.determine_configured_connections ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/role.rb', line 28 def determine_configured_connections role_username_keys = ENV.keys.select { |env_key| env_key.include?(USERNAME_POSTFIX) } role_password_keys = ENV.keys.select { |env_key| env_key.include?(PASSWORD_POSTFIX) } username_configured_roles = role_username_keys.map { |key| username_key_to_name(key) } password_configured_roles = role_password_keys.map { |key| password_key_to_name(key) } password_configured_roles.select do |role| username_configured_roles.include?(role) end end |
.name_to_password_key(name) ⇒ Object
12 13 14 |
# File 'lib/role.rb', line 12 def name_to_password_key(name) "#{name.upcase}#{PASSWORD_POSTFIX}" end |
.name_to_username_key(name) ⇒ Object
8 9 10 |
# File 'lib/role.rb', line 8 def name_to_username_key(name) "#{name.upcase}#{USERNAME_POSTFIX}" end |
.password_key_to_name(key) ⇒ Object
16 17 18 |
# File 'lib/role.rb', line 16 def password_key_to_name(key) key.sub(PASSWORD_POSTFIX, '').downcase end |
.username_key_to_name(key) ⇒ Object
20 21 22 |
# File 'lib/role.rb', line 20 def username_key_to_name(key) key.sub(USERNAME_POSTFIX, '').downcase end |