Module: ROM

Extended by:
Configurable, Global
Includes:
Dry::Core::Constants
Defined in:
lib/rom/core.rb,
lib/rom/cache.rb,
lib/rom/setup.rb,
lib/rom/types.rb,
lib/rom/global.rb,
lib/rom/header.rb,
lib/rom/loader.rb,
lib/rom/mapper.rb,
lib/rom/plugin.rb,
lib/rom/schema.rb,
lib/rom/struct.rb,
lib/rom/command.rb,
lib/rom/gateway.rb,
lib/rom/plugins.rb,
lib/rom/version.rb,
lib/rom/inferrer.rb,
lib/rom/pipeline.rb,
lib/rom/relation.rb,
lib/rom/settings.rb,
lib/rom/attribute.rb,
lib/rom/changeset.rb,
lib/rom/constants.rb,
lib/rom/container.rb,
lib/rom/lint/test.rb,
lib/rom/processor.rb,
lib/rom/auto_curry.rb,
lib/rom/components.rb,
lib/rom/data_proxy.rb,
lib/rom/mapper/dsl.rb,
lib/rom/repository.rb,
lib/rom/initializer.rb,
lib/rom/lint/linter.rb,
lib/rom/open_struct.rb,
lib/rom/plugins/dsl.rb,
lib/rom/transaction.rb,
lib/rom/transformer.rb,
lib/rom/compat/setup.rb,
lib/rom/lint/gateway.rb,
lib/rom/memory/types.rb,
lib/rom/array_dataset.rb,
lib/rom/command_proxy.rb,
lib/rom/commands/lazy.rb,
lib/rom/compat/global.rb,
lib/rom/compat/mapper.rb,
lib/rom/memory/schema.rb,
lib/rom/model_builder.rb,
lib/rom/relation/name.rb,
lib/rom/relation/wrap.rb,
lib/rom/changeset/pipe.rb,
lib/rom/commands/graph.rb,
lib/rom/compat/command.rb,
lib/rom/components/dsl.rb,
lib/rom/memory/dataset.rb,
lib/rom/memory/gateway.rb,
lib/rom/memory/storage.rb,
lib/rom/relation/graph.rb,
lib/rom/commands/create.rb,
lib/rom/commands/delete.rb,
lib/rom/commands/update.rb,
lib/rom/compat/relation.rb,
lib/rom/components/core.rb,
lib/rom/components/view.rb,
lib/rom/mapper_compiler.rb,
lib/rom/memory/commands.rb,
lib/rom/memory/relation.rb,
lib/rom/registries/root.rb,
lib/rom/relation/loaded.rb,
lib/rom/repository/root.rb,
lib/rom/schema/inferrer.rb,
lib/rom/struct_compiler.rb,
lib/rom/changeset/create.rb,
lib/rom/changeset/delete.rb,
lib/rom/changeset/update.rb,
lib/rom/command_compiler.rb,
lib/rom/header/attribute.rb,
lib/rom/mapper/model_dsl.rb,
lib/rom/registries/views.rb,
lib/rom/relation/curried.rb,
lib/rom/compat/components.rb,
lib/rom/compat/registries.rb,
lib/rom/compat/schema/dsl.rb,
lib/rom/components/mapper.rb,
lib/rom/components/schema.rb,
lib/rom/relation/combined.rb,
lib/rom/relation/commands.rb,
lib/rom/support/inflector.rb,
lib/rom/changeset/stateful.rb,
lib/rom/commands/composite.rb,
lib/rom/compat/transformer.rb,
lib/rom/components/command.rb,
lib/rom/components/dataset.rb,
lib/rom/components/gateway.rb,
lib/rom/enumerable_dataset.rb,
lib/rom/processor/composer.rb,
lib/rom/registries/mappers.rb,
lib/rom/registries/schemas.rb,
lib/rom/relation/composite.rb,
lib/rom/repository/session.rb,
lib/rom/support/memoizable.rb,
lib/rom/components/dsl/core.rb,
lib/rom/components/dsl/view.rb,
lib/rom/components/provider.rb,
lib/rom/components/registry.rb,
lib/rom/components/relation.rb,
lib/rom/registries/commands.rb,
lib/rom/registries/datasets.rb,
lib/rom/registries/gateways.rb,
lib/rom/registries/nestable.rb,
lib/rom/changeset/associated.rb,
lib/rom/commands/lazy/create.rb,
lib/rom/commands/lazy/delete.rb,
lib/rom/commands/lazy/update.rb,
lib/rom/compat/setting_proxy.rb,
lib/rom/mapper/attribute_dsl.rb,
lib/rom/registries/container.rb,
lib/rom/registries/relations.rb,
lib/rom/support/configurable.rb,
lib/rom/associations/abstract.rb,
lib/rom/components/dsl/mapper.rb,
lib/rom/components/dsl/schema.rb,
lib/rom/plugins/class_methods.rb,
lib/rom/processor/transformer.rb,
lib/rom/support/notifications.rb,
lib/rom/components/association.rb,
lib/rom/components/dsl/command.rb,
lib/rom/components/dsl/dataset.rb,
lib/rom/components/dsl/gateway.rb,
lib/rom/memory/mapper_compiler.rb,
lib/rom/plugins/command/schema.rb,
lib/rom/associations/one_to_one.rb,
lib/rom/changeset/pipe_registry.rb,
lib/rom/components/dsl/relation.rb,
lib/rom/lint/enumerable_dataset.rb,
lib/rom/registries/associations.rb,
lib/rom/relation/materializable.rb,
lib/rom/schema/associations_dsl.rb,
lib/rom/associations/many_to_one.rb,
lib/rom/associations/one_to_many.rb,
lib/rom/commands/class_interface.rb,
lib/rom/compat/auto_registration.rb,
lib/rom/relation/class_interface.rb,
lib/rom/support/configurable/dsl.rb,
lib/rom/associations/many_to_many.rb,
lib/rom/plugins/schema/timestamps.rb,
lib/rom/components/dsl/association.rb,
lib/rom/plugins/command/timestamps.rb,
lib/rom/plugins/relation/changeset.rb,
lib/rom/repository/class_interface.rb,
lib/rom/repository/relation_reader.rb,
lib/rom/support/configurable/flags.rb,
lib/rom/support/configurable/config.rb,
lib/rom/support/configurable/errors.rb,
lib/rom/compat/components/dsl/schema.rb,
lib/rom/support/configurable/methods.rb,
lib/rom/support/configurable/setting.rb,
lib/rom/support/configurable/version.rb,
lib/rom/changeset/extensions/relation.rb,
lib/rom/support/configurable/compiler.rb,
lib/rom/support/configurable/settings.rb,
lib/rom/commands/graph/class_interface.rb,
lib/rom/commands/graph/input_evaluator.rb,
lib/rom/memory/associations/one_to_one.rb,
lib/rom/associations/one_to_one_through.rb,
lib/rom/associations/through_identifier.rb,
lib/rom/memory/associations/many_to_one.rb,
lib/rom/memory/associations/one_to_many.rb,
lib/rom/memory/associations/many_to_many.rb,
lib/rom/plugins/relation/instrumentation.rb,
lib/rom/plugins/relation/registry_reader.rb,
lib/rom/associations/definitions/abstract.rb,
lib/rom/support/configurable/class_methods.rb,
lib/rom/associations/definitions/one_to_one.rb,
lib/rom/associations/definitions/many_to_one.rb,
lib/rom/associations/definitions/one_to_many.rb,
lib/rom/associations/definitions/many_to_many.rb,
lib/rom/support/configurable/instance_methods.rb,
lib/rom/compat/auto_registration_strategies/base.rb,
lib/rom/associations/definitions/one_to_one_through.rb,
lib/rom/compat/auto_registration_strategies/no_namespace.rb,
lib/rom/compat/auto_registration_strategies/with_namespace.rb,
lib/rom/compat/auto_registration_strategies/custom_namespace.rb

Overview

Constants and errors common in the whole library

Defined Under Namespace

Modules: ArrayDataset, Associations, AutoCurry, AutoRegistrationStrategies, Commands, Components, Configurable, DataProxy, EnumerableDataset, Global, InflectorMethods, Initializer, Lint, Memoizable, Memory, Notifications, Pipeline, Plugins, Registries, SettingProxy, Types Classes: AdapterNotPresentError, Attribute, AutoRegistration, Cache, Changeset, Command, CommandCompiler, CommandProxy, Container, ElementNotFoundError, Gateway, Header, Inferrer, InvalidRelationName, Loader, Mapper, MapperCompiler, ModelBuilder, OpenStruct, Plugin, Processor, Relation, Repository, Schema, Session, Setup, Struct, StructCompiler, Transaction, Transformer

Constant Summary collapse

VERSION =
"6.0.0.alpha1"
CORE_COMPONENTS =
%i[
  gateways
  datasets
  schemas
  relations
  views
  associations
  mappers
  commands
].freeze
AdapterLoadError =
Class.new(StandardError)
ConfigError =
Class.new(StandardError) do
  attr_reader :name, :component, :owner

  # @api private
  def initialize(name, component, reason = :inferrence)
    @name = name
    @component = component
    @owner = component.owner

    key = "#{component.type}.#{name}"

    case reason
    when :inferrence
      super("Failed to infer +#{key}+ setting for #{component.provider}")
    else
      super("#{owner.name} #{key} setting is not valid")
    end
  end
end
EnvAlreadyFinalizedError =
Class.new(StandardError)
GatewayAlreadyDefinedError =
Class.new(StandardError)
DatasetAlreadyDefinedError =
Class.new(StandardError)
SchemaAlreadyDefinedError =
Class.new(StandardError)
RelationAlreadyDefinedError =
Class.new(StandardError)
AssociationAlreadyDefinedError =
Class.new(StandardError)
CommandAlreadyDefinedError =
Class.new(StandardError)
MapperAlreadyDefinedError =
Class.new(StandardError)
MapperMisconfiguredError =
Class.new(StandardError)
NoRelationError =
Class.new(StandardError)
CommandError =
Class.new(StandardError)
KeyMissing =
Class.new(ROM::CommandError)
TupleCountMismatchError =
Class.new(CommandError)
UnknownPluginError =
Class.new(StandardError)
UnsupportedRelationError =
Class.new(StandardError)
MissingAdapterIdentifierError =
Class.new(StandardError)
AttributeAlreadyDefinedError =
Class.new(StandardError)
GatewayMissingError =
Class.new(ElementNotFoundError)
DatasetMissingError =
Class.new(ElementNotFoundError)
SchemaMissingError =
Class.new(ElementNotFoundError)
RelationMissingError =
Class.new(ElementNotFoundError)
MapperMissingError =
Class.new(ElementNotFoundError)
CommandNotFoundError =
Class.new(ElementNotFoundError)
MissingSchemaClassError =
Class.new(StandardError) do
  # @api private
  def initialize(klass)
    super("#{klass.inspect} relation is missing schema_class")
  end
end
MissingSchemaError =
Class.new(StandardError) do
  # @api private
  def initialize(klass)
    super("#{klass.inspect} relation is missing schema definition")
  end
end
MISSING_ELEMENT_ERRORS =
{
  gateways: GatewayMissingError,
  schemas: SchemaMissingError,
  datasets: DatasetMissingError,
  relations: RelationMissingError,
  associations: RelationMissingError,
  commands: CommandNotFoundError,
  mappers: MapperMissingError
}.freeze
DuplicateConfigurationError =
Class.new(StandardError)
DuplicateContainerError =
Class.new(StandardError)
InvalidOptionValueError =
Class.new(StandardError)
InvalidOptionKeyError =
Class.new(StandardError)
Configuration =
Setup
ConfigurationDSL =

TODO: move this to rom/compat

ROM::Components::DSL
Inflector =
Dry::Inflector.new do |i|
  i.plural(/people\z/i, "people")
  i.plural(/schema\z/i, "schemas")
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#adaptersHash<Symbol=>Module> (readonly) Originally defined in module Global

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.

An internal adapter identifier => adapter module map used by setup

Returns:

  • (Hash<Symbol=>Module>)

#handlersPlugins (readonly) Originally defined in module Global

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.

An internal component handler registry

Returns:

Class Method Details

.components(&block) ⇒ Object

Global component setup

Examples:

ROM.components do
  register :cache, handler: MyApp::MyCacheHandler
end


52
53
54
55
56
57
58
59
60
61
# File 'lib/rom/core.rb', line 52

def components(&block)
  if defined?(@_components)
    @_components.instance_eval(&block) if block
    @_components
  else
    require_relative "components"
    @_components = Components
    components(&block)
  end
end

.plugins(*args, &block) ⇒ Object

Global plugin setup

Examples:

ROM.plugins do
  register :publisher, Plugin::Publisher, type: :command
end


71
72
73
74
75
76
77
78
79
80
# File 'lib/rom/core.rb', line 71

def plugins(*args, &block)
  if defined?(@_plugins)
    @_plugins.dsl(*args, &block) if block
    @_plugins
  else
    require_relative "plugins"
    @_plugins = Plugins
    plugins(*args, &block)
  end
end

.Provider(*features, **options) ⇒ Components::Provider

Define a module for component definitions and runtime setup



18
19
20
# File 'lib/rom/components/provider.rb', line 18

def self.Provider(*features, **options)
  Components::Provider.new(features, **options)
end

.register_adapter(identifier, adapter) ⇒ self Originally defined in module Global

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.

Register adapter namespace under a specified identifier

Parameters:

  • identifier (Symbol)
  • adapter (Class, Module)

Returns:

  • (self)

.settingsObject

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.



137
138
139
# File 'lib/rom/settings.rb', line 137

def self.settings
  _settings
end

.setup(*args, &block) ⇒ Object Also known as: container Originally defined in module Global