Sha256: a6dc33871ef1eb0148eff2fffc68d4ae3c2832756e665c6c5fcf52a902781acd

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

module Mobility
  module Backend
    class Sequel::Serialized::QueryMethods < Sequel::QueryMethods
      def initialize(attributes, **options)
        super
        attributes_extractor = @attributes_extractor
        cond_checker = @cond_checker = lambda do |cond|
          if i18n_keys = attributes_extractor.call(cond)
            raise ArgumentError,
              "You cannot query on mobility attributes translated with the Serialized backend (#{i18n_keys.join(", ")})."
          end
        end

        define_method :where do |*cond, &block|
          cond_checker.call(cond.first) || super(*cond, &block)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mobility-0.1.3 lib/mobility/backend/sequel/serialized/query_methods.rb
mobility-0.1.2 lib/mobility/backend/sequel/serialized/query_methods.rb
mobility-0.1.1 lib/mobility/backend/sequel/serialized/query_methods.rb
mobility-0.1.0 lib/mobility/backend/sequel/serialized/query_methods.rb