Sha256: c3bba715e33c9ddc56778fa3a11352c8d6b8368d33573b9d0dc73a9cf434418b
Contents?: true
Size: 781 Bytes
Versions: 2
Compression:
Stored size: 781 Bytes
Contents
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.4.3 | lib/mobility/backends/sequel/query_methods.rb |
mobility-0.4.2 | lib/mobility/backends/sequel/query_methods.rb |