relaxo-model 0.14.0 → 0.15.0

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
- SHA1:
3
- metadata.gz: 0ffd8121a4211d7a2a7784a2bac1b9e41c5e097d
4
- data.tar.gz: 5ff99d733bef43e782787ad2c26b4c7a1fe33078
2
+ SHA256:
3
+ metadata.gz: 3cbc234be302f92a6d89bbafcffe86dc4fb23f15e7b842a0c2709fe3c58a379d
4
+ data.tar.gz: b0359010d799ac743b272b0504fc856b6291ee995d6f6b99f948fa6639d842a8
5
5
  SHA512:
6
- metadata.gz: 03d7a1767e7e18bbe664d1688b40a232b08519cb0447beaf8897d30ebe7c2ad573a27b83585fea00c5ed268d640b5ef86f3c53e7f0cff5814641eb8c137cfbb0
7
- data.tar.gz: 5948aa957ad6b4e3ee4a9c437d03de63722b51865da23a1b26cc5b7765e6d9f8049184678bee0a572825d8f275d698176b92e9aa9e21fe2618c89c98ac3520ba
6
+ metadata.gz: 8a5e23de5cd12df58993661cc1a5c5961407f0113468113aefa09f1e8cf2e5a695e9c1e4d629e7c943646169d69766e3ac79909ee30f37a8776fae8eabc9f7d3
7
+ data.tar.gz: ea6431cf52b2b0225e47e2c2137c3a2346748593fbbec988c31715c84d8bfe3ad861cc9c486c5364dae944fc6b31c522ec125c268f2dac7cc270ec46e602d1b0
@@ -22,6 +22,9 @@ require 'relaxo/model/base'
22
22
 
23
23
  module Relaxo
24
24
  module Model
25
+ class SerializationError < RuntimeError
26
+ end
27
+
25
28
  # Represents an underlying object with changes which can be persisted.
26
29
  module Component
27
30
  def self.included(child)
@@ -131,14 +134,18 @@ module Relaxo
131
134
  # Moves values from `@changed` into `@attributes`.
132
135
  def flatten!
133
136
  self.class.properties.each do |key, klass|
134
- if @changed.include?(key)
135
- if klass
136
- @attributes[key] = klass.convert_to_primative(@changed.delete(key))
137
- else
138
- @attributes[key] = @changed.delete(key)
137
+ begin
138
+ if @changed.include?(key)
139
+ if klass
140
+ @attributes[key] = klass.convert_to_primative(@changed.delete(key))
141
+ else
142
+ @attributes[key] = @changed.delete(key)
143
+ end
144
+ elsif !@attributes.include?(key) and klass.respond_to?(:default)
145
+ @attributes[key] = klass.default
139
146
  end
140
- elsif !@attributes.include?(key) and klass.respond_to?(:default)
141
- @attributes[key] = klass.default
147
+ rescue
148
+ raise SerializationError, "Failed to flatten #{key.inspect} of type #{klass.inspect}!"
142
149
  end
143
150
  end
144
151
 
@@ -133,9 +133,9 @@ module Relaxo
133
133
  end
134
134
 
135
135
  # Make a copy of the record, as if calling create.
136
- def dup
136
+ def dup(dataset = @dataset)
137
137
  # Splat already calls dup internally I guess.
138
- clone = self.class.new(@dataset, nil, @changed.dup, **@attributes)
138
+ clone = self.class.new(dataset, nil, @changed.dup, **@attributes)
139
139
 
140
140
  clone.after_create
141
141
 
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Relaxo
22
22
  module Model
23
- VERSION = "0.14.0"
23
+ VERSION = "0.15.0"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaxo-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-12 00:00:00.000000000 Z
11
+ date: 2018-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaxo
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.6.12
138
+ rubygems_version: 2.7.6
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: A model layer for CouchDB with minimal global state.