Sha256: d759f0f29732b0c5126a81fef6c160b50e44df4ba193e31408a744e1a3c18f53
Contents?: true
Size: 1.13 KB
Versions: 8
Compression:
Stored size: 1.13 KB
Contents
module Mobility module Backend class ActiveRecord::Column::QueryMethods < Backend::ActiveRecord::QueryMethods def initialize(attributes, **options) super attributes_extractor = @attributes_extractor @opts_converter = opts_converter = lambda do |opts| if i18n_keys = attributes_extractor.call(opts) opts = opts.with_indifferent_access i18n_keys.each { |attr| opts[Column.column_name_for(attr)] = opts.delete(attr) } end return opts end define_method :where! do |opts, *rest| super(opts_converter.call(opts), *rest) end attributes.each do |attribute| define_method :"find_by_#{attribute}" do |value| find_by(Column.column_name_for(attribute) => value) end end end def extended(relation) super opts_converter = @opts_converter mod = Module.new do define_method :not do |opts, *rest| super(opts_converter.call(opts), *rest) end end relation.mobility_where_chain.include(mod) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems