flounder 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/flounder.gemspec +1 -1
- data/lib/flounder/entity.rb +5 -3
- data/qed/insdate.md +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4825945deccb5f4203a803ecab116bdcc524314
|
4
|
+
data.tar.gz: bd2ba46841e6f4712b910dcbd4a08ccab9a3ca21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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"
|
data/lib/flounder/entity.rb
CHANGED
@@ -59,13 +59,15 @@ module Flounder
|
|
59
59
|
|
60
60
|
# Insert or update.
|
61
61
|
#
|
62
|
-
def insdate fields, hash
|
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
|
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 |
|
9
|
-
|
10
|
-
end.
|
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 |
|
17
|
-
assert false # Not called.
|
18
|
-
end.
|
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
|
|