Sha256: 1bd7df86d5938bacdd456d30588ad9adefbb48062ca4c254f3bd7dce96a4b07a
Contents?: true
Size: 680 Bytes
Versions: 2
Compression:
Stored size: 680 Bytes
Contents
# frozen_string_literal: true module Hws::Helpers # :nodoc: class Query # :nodoc: class << self def construct_query(base, filter_hash) mut = filter_hash.key?('mutable_tags') ? filter_hash.delete('mutable_tags') : {} immut = filter_hash.key?('immutable_tags') ? filter_hash.delete('immutable_tags') : {} query = base.where(filter_hash) query = query_jsonb(query, 'mutable_tags', mut) query_jsonb(query, 'immutable_tags', immut) end def query_jsonb(base, column_name, filter_hash) return base if filter_hash.empty? base.where("#{column_name} @> ?", filter_hash.to_json) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hws-transactions-0.1.1 | lib/hws-transactions/helpers/query.rb |
hws-transactions-0.1.0 | lib/hws-transactions/helpers/query.rb |