Sha256: 84030937276d74b4fee4c5ac1e1312aeaa2097dab372f953427f06fd59acfff1
Contents?: true
Size: 745 Bytes
Versions: 1
Compression:
Stored size: 745 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.merge(query: query)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
embark-journey-0.1.0 | lib/journey/resource/where_multiple.rb |