Module: ContextualConfig::Concern::SchemaDrivenValidation::ClassMethods
- Defined in:
- lib/contextual_config/concern/schema_driven_validation.rb
Overview
--- Class Methods for Schema Resolution ---
Instance Method Summary collapse
-
#resolve_config_data_schema(_instance = nil) ⇒ Hash?
The JSON schema for config_data, or nil if no schema.
-
#resolve_scoping_rules_schema(_instance = nil) ⇒ Hash?
The JSON schema for scoping_rules, or nil if no schema.
Instance Method Details
#resolve_config_data_schema(_instance = nil) ⇒ Hash?
Returns The JSON schema for config_data, or nil if no schema.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/contextual_config/concern/schema_driven_validation.rb', line 121 def resolve_config_data_schema(_instance = nil) # Try to get schema from module registry first module_config = ContextualConfig.registry.configs_for_model(self).first schema = module_config&.load_schema if module_config return schema if schema # Default implementation: logs a warning and returns nil (no validation). # Consuming classes (or their STI parents/children) MUST override this # to provide their specific schemas. # Example override in consuming class: # @_config_data_schema ||= JSON.parse(File.read(Rails.root.join('config/schemas/my_model/config_data.json'))) log_missing_schema_warning('config_data') nil end |
#resolve_scoping_rules_schema(_instance = nil) ⇒ Hash?
Returns The JSON schema for scoping_rules, or nil if no schema.
138 139 140 141 |
# File 'lib/contextual_config/concern/schema_driven_validation.rb', line 138 def resolve_scoping_rules_schema(_instance = nil) log_missing_schema_warning('scoping_rules') nil end |