Sha256: 99ff469eb9c57ba629f63d3035d887f5ed02fbfca4a329972f60819168f7bec3
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
# frozen_string_literal: true require "rom/components/core" require "rom/components/dataset" require "rom/components/relation" require "rom/components/command" module ROM class Components::Core # @api private def trigger(event, payload) registry.trigger("configuration.#{event}", payload) end # @api private def notifications registry.notifications end end class Components::Dataset < Components::Core mod = Module.new do # @api private def evaluate_block(ds, block) if block.parameters.flatten.include?(:schema) super else ds.instance_exec(relation_constant, &block) end end def relation_constant registry.components.get(:relations, id: relation_id).constant end end prepend(mod) end class Components::Relation < Components::Core mod = Module.new do def build schema = local_components.get(:schemas, id: id)&.build if schema trigger( "relations.schema.set", schema: schema, adapter: adapter, gateway: config[:gateway], relation: constant, registry: registry ) end trigger("relations.class.ready", relation: constant, adapter: adapter) components.update(local_components) relation = super trigger("relations.object.registered", registry: registry, relation: relation) relation end end prepend(mod) end class Components::Command < Components::Core mod = Module.new do def build relation = registry.relations[config.relation] trigger( "commands.class.before_build", command: constant, gateway: registry.gateways[relation.gateway], dataset: relation.dataset, relation: relation, adapter: adapter ) super end end prepend(mod) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-6.0.0.alpha1 | lib/rom/compat/components.rb |