Sha256: 1450e711b518a350a8caed0d367365785cc212541e7fc87b830aaf0ab57ff7bd
Contents?: true
Size: 885 Bytes
Versions: 2
Compression:
Stored size: 885 Bytes
Contents
require "mobility/backends/active_record/query_methods" module Mobility module Backends class ActiveRecord::Column::QueryMethods < ActiveRecord::QueryMethods def initialize(attributes, _) super q = self define_method :where! do |opts, *rest| super(q.convert_opts(opts), *rest) end end def extended(relation) super q = self mod = Module.new do define_method :not do |opts, *rest| super(q.convert_opts(opts), *rest) end end relation.mobility_where_chain.include(mod) end def convert_opts(opts) if i18n_keys = extract_attributes(opts) opts = opts.with_indifferent_access i18n_keys.each { |attr| opts[Column.column_name_for(attr)] = opts.delete(attr) } end opts end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mobility-0.4.3 | lib/mobility/backends/active_record/column/query_methods.rb |
mobility-0.4.2 | lib/mobility/backends/active_record/column/query_methods.rb |