Skip to content

Commit

Permalink
Bring back Michal's great idea about query builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Paakkinen committed Apr 28, 2016
1 parent 5aa9f27 commit 2a68e2c
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions lib/rspec/hive/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ def initialize(schema, connection)
end

def partition(hash)
partition_hash.merge!(hash)
spawn.merge_partition!(hash)
end

def partition!(partition)
partition_hash.merge!(partition)
self
end

def insert(*array)
rows.concat(array)
def insert(*new_rows)
spawn.insert!(new_rows)
end

def insert!(new_rows)
rows.concat(new_rows)
self
end

Expand All @@ -32,14 +40,25 @@ def execute
end

def with_stubbing
spawn.with_stubbing!
end

def with_stubbing!
self.stubbing = true
self
end

protected

attr_accessor :partition_hash, :connection, :rows, :stubbing

private

attr_reader :schema, :partition_hash, :connection, :rows
attr_accessor :stubbing
attr_reader :schema

def spawn
clone
end

def stubbing?
stubbing
Expand Down

0 comments on commit 2a68e2c

Please sign in to comment.