Sha256: 414c2acede1a550be160b1be0086425d24e97dfaee998dbc5ee5bef4b6533d86

Contents?: true

Size: 668 Bytes

Versions: 10

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

module Switchman
  module GuardRail
    module Relation
      def exec_queries(*args)
        if lock_value
          db = Shard.current(connection_class_for_self).database_server
          db.unguard { super }
        else
          super
        end
      end

      %w[update_all delete_all].each do |method|
        arg_params = RUBY_VERSION <= '2.8' ? '*args' : '*args, **kwargs'
        class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{method}(#{arg_params})
            db = Shard.current(connection_class_for_self).database_server
            db.unguard { super }
          end
        RUBY
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
switchman-3.4.2 lib/switchman/guard_rail/relation.rb
switchman-3.4.1 lib/switchman/guard_rail/relation.rb
switchman-3.4.0 lib/switchman/guard_rail/relation.rb
switchman-3.3.7 lib/switchman/guard_rail/relation.rb
switchman-3.3.6 lib/switchman/guard_rail/relation.rb
switchman-3.3.5 lib/switchman/guard_rail/relation.rb
switchman-3.3.4 lib/switchman/guard_rail/relation.rb
switchman-3.3.3 lib/switchman/guard_rail/relation.rb
switchman-3.3.2 lib/switchman/guard_rail/relation.rb
switchman-3.3.1 lib/switchman/guard_rail/relation.rb