Sha256: 41557e72772b14728519f0f57d415cd412c550a28503f3b0215e5aad2b00b5f4
Contents?: true
Size: 879 Bytes
Versions: 11
Compression:
Stored size: 879 Bytes
Contents
require "mobility/backends/sequel/query_methods" module Mobility module Backends class Sequel::Column::QueryMethods < Sequel::QueryMethods def initialize(attributes, _) super attributes_extractor = @attributes_extractor %w[exclude or where].each do |method_name| define_method method_name do |*conds, &block| if keys = attributes_extractor.call(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 attributes.each do |attribute| define_method :"first_by_#{attribute}" do |value| where(attribute.to_sym => value).first end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems