flounder 0.7.1 → 0.8.0

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: ebf8d5e68827d9962affb51d05cf5cd404c73c98
4
- data.tar.gz: 22f1840346a7f36442e93e58b8295e0d5c718358
3
+ metadata.gz: a4825945deccb5f4203a803ecab116bdcc524314
4
+ data.tar.gz: bd2ba46841e6f4712b910dcbd4a08ccab9a3ca21
5
5
  SHA512:
6
- metadata.gz: 6590b22ad34ae153be4d8d56709ca6f4d1f42dfab14908fd713bd4b81123ee5583bf61fddb6743a73c22cb405683e8c1bdf296381b64a4ade1fef432d5ad1c6f
7
- data.tar.gz: a9e0b470deae3ce0edd4f0f33b583e479246ceeb078c8d9191bc464610cbb476a3034978b987d42fa3d828fb40dfbd975c151ea610da1fe16f4b35a88836a218
6
+ metadata.gz: 828e529a485e1714fa19f9986a4c27eeaf264f5edbc92ffe6a41760f59034494049ad05873a5067d7eb734413ad3e6ed8f8ba1367344dac0421d1c86be203e6b
7
+ data.tar.gz: 5d4d28be3d8dea21684440d9ad18b2365860022c2e848aeac637ab38de7b9d8ad333392d5111bfcc3d706d741994e2d6a264ed43d9e7d6a50fab203d5de110ee
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.1'
5
+ s.version = '0.8.0'
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,13 +59,15 @@ module Flounder
59
59
 
60
60
  # Insert or update.
61
61
  #
62
- def insdate fields, hash, &inserted
62
+ def insdate fields, hash
63
63
  with_transaction do
64
64
  found = where(hash.select { |k, _| fields.include?(k) }).first
65
65
  if found
66
- update(hash).where(:id => found.id)
66
+ update(hash).where(:id => found.id).returning
67
67
  else
68
- insert(hash, &inserted)
68
+ result = insert(hash).returning
69
+ yield result if block_given?
70
+ result
69
71
  end
70
72
  end
71
73
  end
data/qed/insdate.md CHANGED
@@ -5,17 +5,17 @@ Flounder offers Insdate.
5
5
 
6
6
  # Insert if not found.
7
7
  #
8
- post = posts.insdate([:title], :title => 'Insdate Insert', :text => '', :user_id => users.first.id) do |u|
9
- u.assert # Is called.
10
- end.returning.first
8
+ post = posts.insdate([:title], :title => 'Insdate Insert', :text => '', :user_id => users.first.id) do |p|
9
+ p.first.title.assert == 'Insdate Insert'
10
+ end.first
11
11
  post.title.assert == 'Insdate Insert'
12
12
  post.text.assert == ''
13
13
 
14
14
  # Update if found with the fields.
15
15
  #
16
- post = posts.insdate([:title], :title => 'Insdate Insert', :text => 'Insdate Update Text') do |u|
17
- assert false # Not called.
18
- end.returning.first
16
+ post = posts.insdate([:title], :title => 'Insdate Insert', :text => 'Insdate Update Text') do |p|
17
+ assert false # Not called on update.
18
+ end.first
19
19
  post.title.assert == 'Insdate Insert'
20
20
  post.text.assert == 'Insdate Update Text'
21
21
 
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.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaspar Schiess