Class: ROM::ConfigurationDSL::Relation

Inherits:
Object
  • Object
show all
Defined in:
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


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

def self.build_class(name, options = EMPTY_HASH)
  inflector = options.fetch(:inflector) { Inflector }
  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