Class: ROM::Components::DSL::Association

Inherits:
Core
  • Object
show all
Defined in:
lib/rom/components/dsl/association.rb

Overview

Setup DSL-specific relation extensions

Instance Method Summary collapse

Instance Method Details

#backendObject

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.



29
30
31
# File 'lib/rom/components/dsl/association.rb', line 29

def backend
  @backend ||= ROM::Schema::AssociationsDSL.new(source, inflector)
end

#callObject

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.



18
19
20
21
22
23
24
25
26
# File 'lib/rom/components/dsl/association.rb', line 18

def call
  configure

  backend.instance_eval(&block)

  backend.call.each do |definition|
    components.add(key, definition: definition, config: config.join(definition, :right))
  end
end

#sourceObject

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.



34
35
36
37
38
39
40
41
42
43
# File 'lib/rom/components/dsl/association.rb', line 34

def source
  if provider.config.component.key?(:id)
    # TODO: decouple associations DSL from Relation::Name
    ROM::Relation::Name[
      provider.config.component.id, provider.config.component.dataset
    ]
  else
    config.source
  end
end