Class: Hyrax::SimpleSchemaLoader Private

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/simple_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

Defined Under Namespace

Classes: AttributeDefinition, UndefinedSchemaError

Instance Method Summary collapse

Instance Method Details

#attributes_for(schema:) ⇒ 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



16
17
18
19
20
# File 'app/services/hyrax/simple_schema_loader.rb', line 16

def attributes_for(schema:)
  definitions(schema).each_with_object({}) do |definition, hash|
    hash[definition.name] = definition.type.meta(definition.config)
  end
end

#form_definitions_for(schema:) ⇒ 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}})


26
27
28
29
30
31
32
# File 'app/services/hyrax/simple_schema_loader.rb', line 26

def form_definitions_for(schema:)
  definitions(schema).each_with_object({}) do |definition, hash|
    next if definition.form_options.empty?

    hash[definition.name] = definition.form_options
  end
end

#index_rules_for(schema:) ⇒ {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



38
39
40
41
42
43
44
# File 'app/services/hyrax/simple_schema_loader.rb', line 38

def index_rules_for(schema:)
  definitions(schema).each_with_object({}) do |definition, hash|
    definition.index_keys.each do |key|
      hash[key] = definition.name
    end
  end
end

#permissive_schema_for_valkrie_adapterObject

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.



46
47
48
49
50
# File 'app/services/hyrax/simple_schema_loader.rb', line 46

def permissive_schema_for_valkrie_adapter
  .each_with_object({}) do |schema_name, ret_hsh|
    predicate_pairs(ret_hsh, schema_name)
  end
end