Sha256: 5541dae99ef85e06fde5df3d2f3c05fa13bca323802d4534d4bfe6001b9208e3
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require "rom/open_struct" require_relative "core" module ROM module Components # @api public class Gateway < Core # @api public def build gateway = adapter.is_a?(ROM::Gateway) ? adapter : setup # TODO: once Gateway is unified with the rest of component types, this # won't be needed as it'll happen automatically when inheriting # config settings gateway_config.plugins.concat(gateway.class.config.component.plugins) gateway.instance_variable_set("@config", gateway_config) gateway.use_logger(config.logger) if config.logger gateway end # @api private def adapter config.adapter end private # @api private def setup if config.args.empty? ROM::Gateway.setup(adapter, **config) else ROM::Gateway.setup(adapter, *config.args) end end # @api private def gateway_config hash = config.to_h keys = hash.keys - %i[type namespace opts] ROM::OpenStruct.new(**keys.zip(hash.values_at(*keys)).to_h, **config.opts) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-6.0.0.alpha1 | lib/rom/components/gateway.rb |