Sha256: fa1259abb64fb72d3d618279c24e52b653c29f3eb6ffd494ddaf685c7283d223
Contents?: true
Size: 773 Bytes
Versions: 2
Compression:
Stored size: 773 Bytes
Contents
module Piglet class Split # :nodoc: include Relation def initialize(relation, expressions) @sources, @expressions = [relation], expressions @shard_map = create_shards end def shards @shard_map.keys end def to_s "SPLIT #{@sources.first.alias} INTO #{split_strings}" end private def create_shards Hash[*@expressions.map { |expr| [RelationShard.new(self), expr] }.flatten] end def split_strings shards.map { |relation| "#{relation.alias} IF #{@shard_map[relation]}" }.join(', ') end end class RelationShard # :nodoc: include Relation def initialize(split) @sources = [split] end def to_s self.alias end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
piglet-0.1.1 | lib/piglet/split.rb |
piglet-0.1.0 | lib/piglet/split.rb |