Class: EventStore::HTTP::Session::Factory
- Inherits:
-
Object
- Object
- EventStore::HTTP::Session::Factory
- Includes:
- Log::Dependency
- Defined in:
- lib/event_store/http/session/factory.rb
Constant Summary collapse
- UnknownType =
Class.new StandardError
Instance Attribute Summary collapse
Class Method Summary collapse
- .build(settings = nil, namespace: nil, type: nil) ⇒ Object
- .call(settings = nil, **arguments) ⇒ Object
- .types ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#type ⇒ Object
11 12 13 |
# File 'lib/event_store/http/session/factory.rb', line 11 def type @type ||= get_type end |
Class Method Details
.build(settings = nil, namespace: nil, type: nil) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/event_store/http/session/factory.rb', line 15 def self.build(settings=nil, namespace: nil, type: nil) settings ||= Settings.instance namespace = Array(namespace) instance = new settings, namespace instance.type = type unless type.nil? instance end |
.call(settings = nil, **arguments) ⇒ Object
24 25 26 27 |
# File 'lib/event_store/http/session/factory.rb', line 24 def self.call(settings=nil, **arguments) instance = build settings, **arguments instance.() end |
Instance Method Details
#call ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/event_store/http/session/factory.rb', line 29 def call logger.trace { "Constructing Session (Type: #{type.inspect})" } cls = resolve_class instance = cls.new settings.set instance, namespace Retry.configure instance, settings, namespace: namespace Log::Data.configure instance, Session, attr_name: :data_logger connect = Connect.configure instance, settings, namespace: namespace instance.configure logger.debug { "Session constructed (Type: #{type.inspect}, Class: #{instance.class})" } instance end |
#get_type ⇒ Object
49 50 51 52 53 |
# File 'lib/event_store/http/session/factory.rb', line 49 def get_type type = settings.get :type, namespace type ||= Defaults.type type.to_sym end |
#resolve_class ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/event_store/http/session/factory.rb', line 55 def resolve_class self.class.types.fetch type do = "Unknown session type (Type: #{type.inspect}, KnownTypes: #{self.class.types.keys.inspect})" logger.error { } raise UnknownType, end end |