module Bmg::Sql::Processor::Transform::SplitSupported
Public Instance Methods
_split_supported(tr, &bl)
click to toggle source
# File lib/bmg/sql/processor/transform.rb, line 33 def _split_supported(tr, &bl) if tr.is_a?(Array) split_supported(tr, &bl) else bl.call(tr) ? [tr, nil] : [nil, tr] end end
split_supported(tr, &bl)
click to toggle source
# File lib/bmg/sql/processor/transform.rb, line 9 def split_supported(tr, &bl) case tr when Array i = tr.find_index{|x| !bl.call(x) } || tr.size [tr[0...i], tr[i..-1]].map{|a| case a.size when 0 then nil when 1 then a.first else a end } when Hash tr.inject([{}, {}]){|(sup,unsup),(k,v)| mine, hers = _split_supported(v, &bl) [ sup.merge(k => mine), unsup.merge(k => hers) ].map(&:compact) }.map{|h| h.empty? ? nil : h } else _split_supported(tr, &bl) end end