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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e7ea9fc5ff2fd2d870ad64879493e0a0e0f65f1
4
- data.tar.gz: f6fa93e1759249ea3fb0e1d66f267d18f99e7ba8
3
+ metadata.gz: 4c9922c516c1a1c45f50723f6e9995ecdbb3f002
4
+ data.tar.gz: cecef390a2b8be3b58b92ee946d8a26f0e0844dd
5
5
  SHA512:
6
- metadata.gz: dc5537112979468f3fe6ca4735f011bb92702a2187c33bcc5d27850f876268368099c9d9af382ce97aa815f5f76699b2b964b4c194a49bd86919609c73662576
7
- data.tar.gz: 610fe12cd6ece4b1c324f4517b461044d75e6d6458d8472789eb50a34f3a179f49bcf9a45e22017e6059db1d261a83736df435d7ba767030638daf3d8a2068f6
6
+ metadata.gz: a3fb663c2ce4616c27e321ea47a045733bcebfb33269c5749b1a392e236bb8753b90ffa49a6488f6408633a7468879d826cbf21c4ca597a9dd3929d6fea2b109
7
+ data.tar.gz: f411881b129fbbaad3c335f0c00ebdab3c9a1ba1a8579cdc101ce748477a14c67a3c478d50dcc61864e28eea143e6f063ceef6105dff94c680c926a9936cacc0
@@ -1,3 +1,3 @@
1
1
  class PGAdaptor
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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(@table).each do |(key, info)|
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.3
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-23 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg