Class: Hyrax::Schema Private

Inherits:
Module
  • Object
show all
Defined in:
lib/hyrax/schema.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.

A module specifying a Schema (set of attributes and types) that can be applied to a ‘Valkyrie::Resource`. This provides the internals for the recommended module builder syntax: `Hyrax::Schema(:schema_name)`

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_name, schema_loader: Hyrax::Schema.simple_schema_loader, schema_version: nil, contexts: []) ⇒ Schema

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.

Note:

use Hyrax::Schema(:my_schema) instead

Returns a new instance of Schema.

Parameters:

  • schema_name (Symbol)


76
77
78
79
80
81
# File 'lib/hyrax/schema.rb', line 76

def initialize(schema_name, schema_loader: Hyrax::Schema.simple_schema_loader, schema_version: nil, contexts: [])
  @name = schema_name.to_s
  @version = schema_version || schema_loader.current_version
  @schema_loader = schema_loader
  @contexts = contexts
end

Instance Attribute Details

#contextsObject (readonly)

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.



59
60
61
# File 'lib/hyrax/schema.rb', line 59

def contexts
  @contexts
end

#nameSymbol (readonly)

Returns:

  • (Symbol)


59
60
61
# File 'lib/hyrax/schema.rb', line 59

def name
  @name
end

#versionObject (readonly)

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.



59
60
61
# File 'lib/hyrax/schema.rb', line 59

def version
  @version
end

Class Method Details

.m3_schema_loaderObject

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.



62
63
64
# File 'lib/hyrax/schema.rb', line 62

def self.m3_schema_loader
  M3SchemaLoader.new
end

.simple_schema_loaderObject

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.



66
67
68
# File 'lib/hyrax/schema.rb', line 66

def self.simple_schema_loader
  SimpleSchemaLoader.new
end

Instance Method Details

#attributesHash{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:

  • (Hash{Symbol => Dry::Types::Type})


85
86
87
# File 'lib/hyrax/schema.rb', line 85

def attributes
  @schema_loader.attributes_for(schema: name, version:, contexts:)
end

#inspectString

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:

  • (String)


91
92
93
# File 'lib/hyrax/schema.rb', line 91

def inspect
  "#{self.class}(#{@name})"
end