flounder 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3cf7329905c8c1b1379adeb8474f9ec7f594b77
4
- data.tar.gz: 9806546b6fbb16077607e0b60930a051fbab9d1f
3
+ metadata.gz: ebf8d5e68827d9962affb51d05cf5cd404c73c98
4
+ data.tar.gz: 22f1840346a7f36442e93e58b8295e0d5c718358
5
5
  SHA512:
6
- metadata.gz: c74c0f97d0a716d094d0af54a3292ba5060c051e913a2b46046942ec92291005474abad4dbe3c692f1391bc3d323d7cd16d514fe92be18d2488f4b4491050156
7
- data.tar.gz: b026b324cc4589a2da8c3ae677dbcbd65ad334637ce97b4ad8af5233180e67265bf396199771f625cad198114ad9c2f7c6974a4cfe98029a38045cd4718ab645
6
+ metadata.gz: 6590b22ad34ae153be4d8d56709ca6f4d1f42dfab14908fd713bd4b81123ee5583bf61fddb6743a73c22cb405683e8c1bdf296381b64a4ade1fef432d5ad1c6f
7
+ data.tar.gz: a9e0b470deae3ce0edd4f0f33b583e479246ceeb078c8d9191bc464610cbb476a3034978b987d42fa3d828fb40dfbd975c151ea610da1fe16f4b35a88836a218
data/flounder.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "flounder"
5
- s.version = '0.7.0'
5
+ s.version = '0.7.1'
6
6
  s.summary = "Flounder is a way to write SQL simply in Ruby. It deals with everything BUT object relational mapping. "
7
7
  s.email = "kaspar.schiess@technologyastronauts.ch"
8
8
  s.homepage = "https://bitbucket.org/technologyastronauts/laboratory_flounder"
@@ -59,17 +59,25 @@ module Flounder
59
59
 
60
60
  # Insert or update.
61
61
  #
62
- # TODO Envelop in transaction.
63
- # Not sure yet where the right level of abstraction is to
64
- # insert START TRANSACTION/COMMIT TRANSACTION.
65
- #
66
62
  def insdate fields, hash, &inserted
67
- found = where(hash.select { |k, _| fields.include?(k) }).first
68
- if found
69
- update(hash).where(:id => found.id)
70
- else
71
- insert(hash, &inserted)
63
+ with_transaction do
64
+ found = where(hash.select { |k, _| fields.include?(k) }).first
65
+ if found
66
+ update(hash).where(:id => found.id)
67
+ else
68
+ insert(hash, &inserted)
69
+ end
70
+ end
71
+ end
72
+
73
+ def with_transaction &block
74
+ result = nil
75
+ domain.connection_pool.with_connection do |conn|
76
+ conn.exec 'START TRANSACTION'
77
+ result = block.call
78
+ conn.exec 'COMMIT TRANSACTION'
72
79
  end
80
+ result
73
81
  end
74
82
 
75
83
  # Temporarily creates a new entity that is available as if it was declared
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flounder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaspar Schiess