Class: Hyrax::M3SchemaLoader Private

Inherits:
SchemaLoader show all
Defined in:
app/services/hyrax/m3_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.

Read m3 profiles from the database

See Also:

  • for an example configuration

Instance Method Summary collapse

Methods inherited from SchemaLoader

#attributes_for, #form_definitions_for, #index_rules_for

Instance Method Details

#config_paths(schema_name = 'm3_profile') ⇒ 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.



20
21
22
23
24
25
# File 'app/services/hyrax/m3_schema_loader.rb', line 20

def config_paths(schema_name = 'm3_profile')
  config_search_paths.collect do |root_path|
    path = root_path.to_s + "/config/metadata_profiles/#{schema_name}.yaml"
    path if File.exist?(path)
  end.compact
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.



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

def current_version
  Hyrax::FlexibleSchema.current_schema_id
rescue ActiveRecord::StatementInvalid # allow for moments when the database is not yet initialized
  0
end

#view_definitions_for(schema:, version: 1, contexts: nil) ⇒ 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.



11
12
13
14
15
16
17
18
# File 'app/services/hyrax/m3_schema_loader.rb', line 11

def view_definitions_for(schema:, version: 1, contexts: nil)
  definitions(schema, version, contexts).each_with_object({}) do |definition, hash|
    view_options = definition.view_options
    next if view_options.without(:display_label).empty?

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