Class: ROM::Registries::Schemas

Inherits:
Root
  • Object
show all
Includes:
Nestable
Defined in:
lib/rom/registries/schemas.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ROM::Registries::Root

Instance Method Details

#canonical(provider) ⇒ Schema

Resolve relation's canonical schema

Parameters:

  • provider (#config)

Returns:



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rom/registries/schemas.rb', line 17

def canonical(provider)
  schema = scoped(provider.config.component.id).fetch(provider.config.component.dataset) {
    fetch(provider.config.component.id)
  }

  if schema.is_a?(self.class)
    unscoped.fetch(provider.config.component.id)
  else
    schema
  end
end

#define_component(**options) ⇒ 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.



35
36
37
38
39
40
41
# File 'lib/rom/registries/schemas.rb', line 35

def define_component(**options)
  return super unless provider_type == :relation

  comp = components.get(:schemas, relation: config.component.id, abstract: false)

  comp || super(**options, relation_id: config.component.id)
end

#fetch(key, &block) ⇒ Object Also known as: [] Originally defined in module Nestable

#unscopedObject

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
# File 'lib/rom/registries/schemas.rb', line 30

def unscoped
  root.schemas
end