Sha256: 8983b42e64b97eb5825284b6700ec9abf98481bdb5d33dbf1ba6704ace81ab25
Contents?: true
Size: 838 Bytes
Versions: 2
Compression:
Stored size: 838 Bytes
Contents
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 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mobility-0.4.1 | lib/mobility/backends/sequel/column/query_methods.rb |
mobility-0.4.0 | lib/mobility/backends/sequel/column/query_methods.rb |