lib/grumlin/config.rb in grumlin-0.23.0 vs lib/grumlin/config.rb in grumlin-1.0.0.rc1
- old
+ new
@@ -1,41 +1,41 @@
# frozen_string_literal: true
-module Grumlin
- class Config
- attr_accessor :url, :pool_size, :client_concurrency, :client_factory, :provider
+class Grumlin::Config
+ attr_accessor :url, :pool_size, :client_concurrency, :client_factory, :provider
- SUPPORTED_PROVIDERS = %i[neptune tinkergraph].freeze
+ SUPPORTED_PROVIDERS = [:neptune, :tinkergraph].freeze
- DEFAULT_MIDDLEWARES = Middleware::Builder.new do |b|
- b.use Middlewares::SerializeToSteps
- b.use Middlewares::ApplyShortcuts
- b.use Middlewares::SerializeToBytecode
- b.use Middlewares::BuildQuery
- b.use Middlewares::CastResults
- b.use Middlewares::RunQuery
- end.freeze
+ DEFAULT_MIDDLEWARES = Grumlin::Middlewares::Builder.new do |b|
+ b.use Grumlin::Middlewares::SerializeToSteps
+ b.use Grumlin::Middlewares::ApplyShortcuts
+ b.use Grumlin::Middlewares::SerializeToBytecode
+ b.use Grumlin::Middlewares::BuildQuery
+ b.use Grumlin::Middlewares::CastResults
+ b.use Grumlin::Middlewares::RunQuery
+ end
- class ConfigurationError < Grumlin::Error; end
+ class ConfigurationError < Grumlin::Error; end
- class UnknownProviderError < ConfigurationError; end
+ class UnknownProviderError < ConfigurationError; end
- def initialize
- @pool_size = 10
- @client_concurrency = 5
- @provider = :tinkergraph
- @client_factory = ->(url, parent) { Grumlin::Client.new(url, parent: parent) }
- end
+ def initialize
+ @pool_size = 10
+ @client_concurrency = 5
+ @provider = :tinkergraph
+ @client_factory = ->(url, parent) { Grumlin::Client.new(url, parent: parent) }
+ end
- def middlewares
- @middlewares ||= Middleware::Builder.new do |b|
- b.use DEFAULT_MIDDLEWARES
- end
+ def middlewares
+ @middlewares ||= Grumlin::Middlewares::Builder.new do |b|
+ b.use DEFAULT_MIDDLEWARES
end
+ yield(@middlewares) if block_given?
+ @middlewares
+ end
- def validate!
- return if SUPPORTED_PROVIDERS.include?(provider.to_sym)
+ def validate!
+ return if SUPPORTED_PROVIDERS.include?(provider.to_sym)
- raise UnknownProviderError, "provider '#{provider}' is unknown. Supported providers: #{SUPPORTED_PROVIDERS}"
- end
+ raise UnknownProviderError, "provider '#{provider}' is unknown. Supported providers: #{SUPPORTED_PROVIDERS}"
end
end