Class: ROM::ConfigurationDSL::Relation

Inherits:
Object
  • Object
show all
Defined in:
core/lib/rom/configuration_dsl/relation.rb

Overview

Setup DSL-specific relation extensions

Class Method Summary collapse

Class Method Details

.build_class(name, options = EMPTY_HASH) ⇒ 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.

Generate a relation subclass

This is used by Setup#relation DSL



16
17
18
19
20
21
22
23
24
# File 'core/lib/rom/configuration_dsl/relation.rb', line 16

def self.build_class(name, options = EMPTY_HASH)
  class_name = "ROM::Relation[#{Inflector.camelize(name)}]"
  adapter = options.fetch(:adapter)

  Dry::Core::ClassBuilder.new(name: class_name, parent: ROM::Relation[adapter]).call do |klass|
    klass.gateway(options.fetch(:gateway, :default))
    klass.schema(name) {}
  end
end