pg_adaptor 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pg_adaptor/version.rb +1 -1
- data/lib/pg_adaptor.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c9922c516c1a1c45f50723f6e9995ecdbb3f002
|
4
|
+
data.tar.gz: cecef390a2b8be3b58b92ee946d8a26f0e0844dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3fb663c2ce4616c27e321ea47a045733bcebfb33269c5749b1a392e236bb8753b90ffa49a6488f6408633a7468879d826cbf21c4ca597a9dd3929d6fea2b109
|
7
|
+
data.tar.gz: f411881b129fbbaad3c335f0c00ebdab3c9a1ba1a8579cdc101ce748477a14c67a3c478d50dcc61864e28eea143e6f063ceef6105dff94c680c926a9936cacc0
|
data/lib/pg_adaptor/version.rb
CHANGED
data/lib/pg_adaptor.rb
CHANGED
@@ -7,6 +7,7 @@ class PGAdaptor
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize name, klass
|
10
|
+
@name = name
|
10
11
|
@table = self.class.db[name]
|
11
12
|
@klass = klass
|
12
13
|
end
|
@@ -46,12 +47,13 @@ private
|
|
46
47
|
|
47
48
|
def process(model)
|
48
49
|
schema = {}
|
49
|
-
self.class.db.schema(@
|
50
|
+
self.class.db.schema(@name).each do |(key, info)|
|
50
51
|
schema[key] = info
|
51
52
|
end
|
52
53
|
fields = {}
|
53
54
|
model.each_pair do |field,value|
|
54
55
|
next if field == :id && value.nil?
|
56
|
+
raise "Field not present in schema: #{field}" unless schema[field]
|
55
57
|
case schema[field][:db_type]
|
56
58
|
when "jsonb" then fields[field] = Sequel.pg_jsonb value
|
57
59
|
when /\[\]$/ then fields[field] = Sequel.pg_array value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_adaptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Rowe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|