Module: PgEventstore::Extensions::UsingConnectionExtension::ClassMethods
- Defined in:
- lib/pg_eventstore/extensions/using_connection_extension.rb
Instance Method Summary collapse
Instance Method Details
#connection ⇒ Object
15 16 17 |
# File 'lib/pg_eventstore/extensions/using_connection_extension.rb', line 15 def connection raise("No connection was set. Are you trying to manipulate #{name} outside of its lifecycle?") end |
#using_connection(config_name) ⇒ Class<PgEventstore::Subscription>
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pg_eventstore/extensions/using_connection_extension.rb', line 21 def using_connection(config_name) original_class = self Class.new(original_class).tap do |klass| klass.define_singleton_method(:connection) { PgEventstore.connection(config_name) } klass.class_eval do %i[to_s inspect name].each do |m| define_singleton_method(m, &original_class.method(m)) end end end end |