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 +5 -5
- data/lib/relaxo/model/component.rb +14 -7
- data/lib/relaxo/model/document.rb +2 -2
- data/lib/relaxo/model/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3cbc234be302f92a6d89bbafcffe86dc4fb23f15e7b842a0c2709fe3c58a379d
|
4
|
+
data.tar.gz: b0359010d799ac743b272b0504fc856b6291ee995d6f6b99f948fa6639d842a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
135
|
-
if
|
136
|
-
|
137
|
-
|
138
|
-
|
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
|
-
|
141
|
-
|
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(
|
138
|
+
clone = self.class.new(dataset, nil, @changed.dup, **@attributes)
|
139
139
|
|
140
140
|
clone.after_create
|
141
141
|
|
data/lib/relaxo/model/version.rb
CHANGED
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.
|
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-
|
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
|
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.
|