Class: Hyrax::SchemaLoader Private
- Inherits:
-
Object
- Object
- Hyrax::SchemaLoader
- Defined in:
- app/services/hyrax/schema_loader.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This is a simple yaml config-driven schema loader
Direct Known Subclasses
Defined Under Namespace
Classes: AttributeDefinition, UndefinedSchemaError
Instance Method Summary collapse
-
#attributes_for(schema:, version: 1, contexts: nil) ⇒ Hash<Symbol, Dry::Types::Type>
private
A map from attribute names to types.
- #current_version ⇒ Object private
- #form_definitions_for(schema:, version: 1, contexts: nil) ⇒ Hash{Symbol => Hash{Symbol => Object}} private
-
#index_rules_for(schema:, version: 1, contexts: nil) ⇒ {Symbol => Symbol}
private
A map from index keys to attribute names.
Instance Method Details
#attributes_for(schema:, version: 1, contexts: nil) ⇒ Hash<Symbol, Dry::Types::Type>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a map from attribute names to types.
18 19 20 21 22 |
# File 'app/services/hyrax/schema_loader.rb', line 18 def attributes_for(schema:, version: 1, contexts: nil) definitions(schema, version, contexts).each_with_object({}) do |definition, hash| hash[definition.name] = definition.type.(definition.config) end end |
#current_version ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 |
# File 'app/services/hyrax/schema_loader.rb', line 48 def current_version 1 end |
#form_definitions_for(schema:, version: 1, contexts: nil) ⇒ Hash{Symbol => Hash{Symbol => Object}}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 31 32 33 34 |
# File 'app/services/hyrax/schema_loader.rb', line 28 def form_definitions_for(schema:, version: 1, contexts: nil) definitions(schema, version, contexts).each_with_object({}) do |definition, hash| next if definition..empty? hash[definition.name] = definition. end end |
#index_rules_for(schema:, version: 1, contexts: nil) ⇒ {Symbol => Symbol}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a map from index keys to attribute names.
40 41 42 43 44 45 46 |
# File 'app/services/hyrax/schema_loader.rb', line 40 def index_rules_for(schema:, version: 1, contexts: nil) definitions(schema, version, contexts).each_with_object({}) do |definition, hash| definition.index_keys.each do |key| hash[key] = definition.name end end end |