Class: TemplateArguments
- Inherits:
-
Object
- Object
- TemplateArguments
- Defined in:
- lib/arkana/models/template_arguments.rb
Overview
A class that defines template arguments in a language-agnostic form.
Instance Method Summary collapse
- #environment_protocol_secrets(environment) ⇒ Object
-
#generate_test_secret(key:) ⇒ Object
Generates a new test secret for a given key, using the salt stored.
-
#get_binding ⇒ Object
Expose private ‘binding` method.
-
#initialize(environment_secrets:, global_secrets:, config:, salt:) ⇒ TemplateArguments
constructor
Generates template arguments for the given secrets and config specifications.
Constructor Details
#initialize(environment_secrets:, global_secrets:, config:, salt:) ⇒ TemplateArguments
Generates template arguments for the given secrets and config specifications.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/arkana/models/template_arguments.rb', line 8 def initialize(environment_secrets:, global_secrets:, config:, salt:) # The environments declared in the config file. @environments = config.environments # The salt used to encode all the secrets. @salt = salt # The encoded environment-specific secrets. @environment_secrets = environment_secrets # The encoded global secrets. @global_secrets = global_secrets # Name of the import statements (or the interfaces' prefixes). @import_name = config.import_name # Name of the pod that should be generated. @pod_name = config.pod_name # The top level namespace in which the keys will be generated. Often an enum. @namespace = config.namespace # The property declaration strategy declared in the config file. @swift_declaration_strategy = config.swift_declaration_strategy # Whether unit tests should be generated. @should_generate_unit_tests = config.should_generate_unit_tests end |
Instance Method Details
#environment_protocol_secrets(environment) ⇒ Object
29 30 31 32 33 |
# File 'lib/arkana/models/template_arguments.rb', line 29 def environment_protocol_secrets(environment) @environment_secrets.select do |secret| secret.environment == environment end end |
#generate_test_secret(key:) ⇒ Object
Generates a new test secret for a given key, using the salt stored.
36 37 38 39 40 |
# File 'lib/arkana/models/template_arguments.rb', line 36 def generate_test_secret(key:) # Yes, we encode the key as the value because this is just for testing purposes encoded_value = Encoder.encode(key, @salt.raw) Secret.new(key: key, protocol_key: key, encoded_value: encoded_value, type: :string) end |
#get_binding ⇒ Object
Expose private ‘binding` method. rubocop:disable Naming/AccessorMethodName
44 45 46 |
# File 'lib/arkana/models/template_arguments.rb', line 44 def get_binding binding end |