Module: Sequel
- Defined in:
- lib/sequel/extensions/connection_guard.rb,
lib/sequel/extensions/connection_guard/dataset.rb,
lib/sequel/extensions/connection_guard/executor.rb,
lib/sequel/extensions/connection_guard/model_guard.rb,
lib/sequel/extensions/connection_guard/database_guard.rb,
lib/sequel/extensions/connection_guard/connection_guard.rb,
lib/sequel/extensions/connection_guard/configuration_error.rb
Overview
Defined Under Namespace
Modules: ConnectionGuard
Constant Summary collapse
- DatabaseGuard =
ConnectionGuard::DatabaseGuard
Class Method Summary collapse
-
.ModelGuard(ds, &class_body) ⇒ Object
A constructor for model guards.
Class Method Details
.ModelGuard(ds, &class_body) ⇒ Object
A constructor for model guards.
rubocop:disable Naming/MethodName
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/sequel/extensions/connection_guard.rb', line 48 def self.ModelGuard(ds, &class_body) model = ConnectionGuard::ModelGuard.new(ds, &class_body) Class.new.tap do |klass| klass.define_singleton_method(:safe_execute) do |&block| model.safe_execute(&block) end klass.define_singleton_method(:force_execute) do |&block| model.force_execute(&block) end klass.define_singleton_method(:const_missing) do |const_name| if const_name == :RawModel model.raw_model else super(const_name) end end end end |