Sha256: 064b2c3d9e406ccc5109e810811c73bda9b1c03d49341983ec1e94bd938e1038
Contents?: true
Size: 811 Bytes
Versions: 2
Compression:
Stored size: 811 Bytes
Contents
# frozen_string_literal: true require "mobility/util" module Mobility module Backends module Sequel =begin Defines query method overrides to handle translated attributes for Sequel models. For details see backend-specific subclasses. =end class QueryMethods < Module # @param [Array<String>] attributes Translated attributes def initialize(attributes, _) @attributes = attributes.map!(&:to_sym) attributes.each do |attribute| define_method :"first_by_#{attribute}" do |value| where(attribute.to_sym => value).select_all(model.table_name).first end end end def extract_attributes(cond) cond.is_a?(Hash) && Util.presence(cond.keys & @attributes) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mobility-0.5.1 | lib/mobility/backends/sequel/query_methods.rb |
mobility-0.5.0 | lib/mobility/backends/sequel/query_methods.rb |