Sha256: 1fc0dd5e66bb697cb7fb47dbd7af113a4aac9cdf348b466e252e0c90a495f62b

Contents?: true

Size: 691 Bytes

Versions: 2

Compression:

Stored size: 691 Bytes

Contents

# frozen_string_literal: true
require "mobility/backends/sequel/query_methods"

module Mobility
  module Backends
    class Sequel::Column::QueryMethods < Sequel::QueryMethods
      def initialize(attributes, _)
        super
        q = self

        %w[exclude or where].each do |method_name|
          define_method method_name do |*conds, &block|
            if keys = q.extract_attributes(conds.first)
              cond = conds.first.dup
              keys.each { |attr| cond[Column.column_name_for(attr)] = cond.delete(attr) }
              super(cond, &block)
            else
              super(*conds, &block)
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mobility-0.5.1 lib/mobility/backends/sequel/column/query_methods.rb
mobility-0.5.0 lib/mobility/backends/sequel/column/query_methods.rb