Sha256: bd7d944f0eb75ecb4da8b1e67b0e44d6e7cd7305217455c58978a4b675a497f1
Contents?: true
Size: 725 Bytes
Versions: 1
Compression:
Stored size: 725 Bytes
Contents
require 'active_support/concern' module Journey::Resource::WhereMultiple extend ActiveSupport::Concern included do def self.where_multiple(clauses) query = clauses.delete(:query) query_keys_with_array_values = query.map do |key, value| key if value.is_a?(Array) end.compact if branch_key = query_keys_with_array_values.first consistent_query = query.except(branch_key) value_branches = query[branch_key] value_branches.map do |value| branch_query = consistent_query.merge(branch_key => value) where_multiple(clauses.merge(query: branch_query)) end.map(&:to_a).sum else where(clauses) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
embark-journey-0.0.29 | lib/journey/resource/where_multiple.rb |