Class: Console1984::Config
- Inherits:
-
Object
- Object
- Console1984::Config
- Includes:
- Freezeable, Messages
- Defined in:
- lib/console1984/config.rb
Overview
Container for config options.
These config options are accessible via first-level reader methods at Console1984.
Constant Summary collapse
- PROTECTIONS_CONFIG_FILE_PATH =
Console1984::Engine.root.join("config/protections.yml")
- PROPERTIES =
%i[ session_logger username_resolver ask_for_username_if_empty shield command_executor protected_environments protected_urls production_data_warning enter_unprotected_encryption_mode_warning enter_protected_mode_warning incinerate incinerate_after incineration_queue protections_config base_record_class debug test_mode ]
Constants included from Messages
Messages::COMMANDS, Messages::DEFAULT_ENTER_PROTECTED_MODE_WARNING, Messages::DEFAULT_ENTER_UNPROTECTED_ENCRYPTION_MODE_WARNING, Messages::DEFAULT_PRODUCTION_DATA_WARNING
Instance Method Summary collapse
- #freeze ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#protections_config ⇒ Object
Initialize lazily so that it only gets instantiated during console sessions.
- #set_from(properties) ⇒ Object
Methods included from Freezeable
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
21 22 23 |
# File 'lib/console1984/config.rb', line 21 def initialize set_defaults end |
Instance Method Details
#freeze ⇒ Object
36 37 38 39 |
# File 'lib/console1984/config.rb', line 36 def freeze super [ protected_urls, protections_config ].each(&:freeze) end |
#protections_config ⇒ Object
Initialize lazily so that it only gets instantiated during console sessions
32 33 34 |
# File 'lib/console1984/config.rb', line 32 def protections_config @protections_config ||= Console1984::ProtectionsConfig.new(YAML.safe_load(File.read(PROTECTIONS_CONFIG_FILE_PATH)).symbolize_keys) end |
#set_from(properties) ⇒ Object
25 26 27 28 29 |
# File 'lib/console1984/config.rb', line 25 def set_from(properties) properties.each do |key, value| public_send("#{key}=", value) if value.present? end end |