Class: Hyrax::M3SchemaLoader Private

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

Defined Under Namespace

Classes: M3AttributeDefinition

Instance Method Summary collapse

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.



23
24
25
26
27
28
# File 'app/services/hyrax/m3_schema_loader.rb', line 23

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.



30
31
32
33
34
# File 'app/services/hyrax/m3_schema_loader.rb', line 30

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
19
20
21
# 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
    # display_label, admin_only, and editor_only keys are always added to
    # the view_options hash. If there are no other view options, skip this
    # field.
    next if view_options.without(:display_label, :admin_only, :editor_only).empty?

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