Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce multi files for authorization definitions #602

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/authorization_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AuthorizationDefinition < StaticApplicationRecord
:public

def self.all
Rails.application.config_for(:authorization_definitions).map do |uid, hash|
build(uid, hash)
AuthorizationDefinitionConfigurations.instance.all.map do |uid, hash|
build(uid, hash.deep_symbolize_keys)
end
end

Expand Down
29 changes: 29 additions & 0 deletions app/services/abstract_yaml_configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class AbstractYAMLConfiguration
include Singleton

def all
config
end

protected

def files
fail NotImplementedError
end

private

def config
@config ||= YAML.load(config_interpolated, aliases: true)
end

def config_interpolated
ERB.new(config_raw).result
end

def config_raw
files.inject('') do |final_payload, file|
final_payload << "#{File.read(file)}\n"
end
end
end
5 changes: 5 additions & 0 deletions app/services/authorization_definition_configurations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AuthorizationDefinitionConfigurations < AbstractYAMLConfiguration
def files
Dir[Rails.root.join('config/authorization_definitions/*.y*ml').to_s]
end
end
26 changes: 2 additions & 24 deletions app/services/authorization_request_form_configurations.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
class AuthorizationRequestFormConfigurations
include Singleton

def all
config
end

private

def config
@config ||= YAML.load(config_interpolated, aliases: true)
end

def config_interpolated
ERB.new(config_raw).result
end

def config_raw
data_providers_files.inject('') do |final_payload, file|
final_payload << "#{File.read(file)}\n"
end
end

def data_providers_files
class AuthorizationRequestFormConfigurations < AbstractYAMLConfiguration
def files
Dir[Rails.root.join('config/authorization_request_forms/*.y*ml').to_s]
end
end
Loading
Loading