Class: Hyrax::SchemaLoader Private

Inherits:
Object
  • Object
show all
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

See Also:

  • for an example configuration

Direct Known Subclasses

M3SchemaLoader, SimpleSchemaLoader

Defined Under Namespace

Classes: AttributeDefinition, UndefinedSchemaError

Instance Method Summary collapse

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.

Parameters:

  • schema (Symbol)

Returns:

  • (Hash<Symbol, Dry::Types::Type>)

    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.meta(definition.config)
  end
end

#current_versionObject

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.

Parameters:

  • schema (Symbol)

Returns:

  • (Hash{Symbol => Hash{Symbol => Object}})


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.form_options.empty?

    hash[definition.name] = definition.form_options
  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.

Parameters:

  • schema (Symbol)

Returns:

  • ({Symbol => Symbol})

    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