lib/pdk/config/json_schema_setting.rb in pdk-2.7.1 vs lib/pdk/config/json_schema_setting.rb in pdk-3.0.0
- old
+ new
@@ -6,10 +6,11 @@
# Initialises the PDK::Config::JSONSchemaSetting object.
#
# @see PDK::Config::Setting.initialize
def initialize(_name, namespace, _initial_value)
raise 'The JSONSchemaSetting object can only be created within the JSONSchemaNamespace' unless namespace.is_a?(PDK::Config::JSONSchemaNamespace)
+
super
end
# Verifies that the new setting value is valid by calling the JSON schema validator on
# a hash which includes the new setting
@@ -22,14 +23,11 @@
new_document[@name] = value
begin
# ... add validate it
namespace.validate_document!(new_document)
rescue ::JSON::Schema::ValidationError => e
- raise ArgumentError, '%{key} %{message}' % {
- key: qualified_name,
- message: e.message,
- }
+ raise ArgumentError, format('%{key} %{message}', key: qualified_name, message: e.message)
end
end
# Evaluate the default setting, firstly from the JSON schema and then
# from any other default evaluators in the settings chain.
@@ -44,10 +42,10 @@
prop_schema = namespace.schema['properties'][@name]
return prop_schema['default'] unless prop_schema['default'].nil?
end
# ... otherwise call the settings chain default
# and if that doesn't exist, just return nil
- @previous_setting.nil? ? nil : @previous_setting.default
+ @previous_setting&.default
end
end
end
end