Class: ROM::Components::Relation

Inherits:
Core
  • Object
show all
Defined in:
lib/rom/components/relation.rb,
lib/rom/compat/components.rb

Instance Attribute Summary collapse

Attributes inherited from Core

#config, #gateway, #provider

Instance Method Summary collapse

Methods inherited from Core

#abstract, #apply_external_plugins, #apply_plugins, #components, #gateway?, #gateway_plugins, #id, #inflector, inherited, #key, #namespace, #notifications, #plugin_options, #plugins, #provider_plugins, #trigger, #type

Methods included from Initializer

extended

Instance Attribute Details

#constant.new (readonly)

Returns Relation instance builder (typically a class).

Returns:

  • (.new)

    Relation instance builder (typically a class)



11
# File 'lib/rom/components/relation.rb', line 11

option :constant, type: Types.Interface(:new)

Instance Method Details

#adapterObject



31
32
33
# File 'lib/rom/components/relation.rb', line 31

def adapter
  config.adapter
end

#buildROM::Relation

Returns:



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

def build
  constant.use(:changeset)
  constant.use(:registry_reader, relations: registry.relation_ids)

  # Define view methods if there are any registered view components for this relation
  local_components.views(relation_id: id).each do |view|
    view.define(constant)
  end

  apply_plugins

  constant.new(inflector: inflector, registry: registry, **plugin_options)
end

#local_componentsObject

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.



36
37
38
# File 'lib/rom/components/relation.rb', line 36

def local_components
  constant.components
end