lib/hanami/model/configuration.rb in hanami-model-1.2.0 vs lib/hanami/model/configuration.rb in hanami-model-1.3.0.beta1
- old
+ new
@@ -45,18 +45,24 @@
# @api private
attr_reader :url
# NOTE: This must be changed when we want to support several adapters at the time
#
+ # @raise [Hanami::Model::UnknownDatabaseAdapterError] if `url` is blank,
+ # or it uses an unknown adapter.
+ #
# @since 0.7.0
# @api private
def connection
gateway.connection
end
# NOTE: This must be changed when we want to support several adapters at the time
#
+ # @raise [Hanami::Model::UnknownDatabaseAdapterError] if `url` is blank,
+ # or it uses an unknown adapter.
+ #
# @since 0.7.0
# @api private
def gateway
gateways[:default]
end
@@ -120,15 +126,24 @@
def logger=(value)
return if value.nil?
gateway.use_logger(@logger = value)
end
+ # @raise [Hanami::Model::UnknownDatabaseAdapterError] if `url` is blank,
+ # or it uses an unknown adapter.
+ #
# @since 1.0.0
# @api private
def rom
@rom ||= ROM::Configuration.new(@backend, @url, infer_relations: false)
+ rescue => e
+ raise UnknownDatabaseAdapterError.new(@url) if e.message =~ /adapters/
+ raise e
end
+ # @raise [Hanami::Model::UnknownDatabaseAdapterError] if `url` is blank,
+ # or it uses an unknown adapter.
+ #
# @since 1.0.0
# @api private
def load!(repositories, &blk) # rubocop:disable Metrics/AbcSize
rom.setup.auto_registration(config.directory.to_s) unless config.directory.nil?
rom.instance_eval(&blk) if block_given?