relaxo-model 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaxo/model/document.rb +24 -0
- data/lib/relaxo/model/version.rb +1 -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: ed8c070f4630e99c32c46328cab4ced85740c870
|
4
|
+
data.tar.gz: 2b48dbeb94ae7e9a445c37f4b98d9e935066f54c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5a2ae77cd8ad70daefe36ca1b1e1b488956581d9fb97a1967eec23d315ab928057e04cb5763e4640ebf4591c178d628cb8eafe2d793990d7e67342ccf32b381
|
7
|
+
data.tar.gz: 28a8fa57737965ef253c413a2c678592d4ebbb267e0aeb07b7bb6dfd59b454dac512e9402ba4a49165b3a2d3be1dada5022990a8a2e80761d3d587a0cb9456aa
|
@@ -22,6 +22,18 @@ require 'relaxo/model/component'
|
|
22
22
|
|
23
23
|
module Relaxo
|
24
24
|
module Model
|
25
|
+
class ValidationError < StandardError
|
26
|
+
def initialize(document, errors)
|
27
|
+
@document = document
|
28
|
+
@errors = errors
|
29
|
+
|
30
|
+
super "Failed to validate document #{@document} because: #{@errors.join(', ')}!"
|
31
|
+
end
|
32
|
+
|
33
|
+
attr :document
|
34
|
+
attr :errors
|
35
|
+
end
|
36
|
+
|
25
37
|
module Document
|
26
38
|
TYPE = 'type'
|
27
39
|
|
@@ -113,6 +125,18 @@ module Relaxo
|
|
113
125
|
@database.save(@attributes)
|
114
126
|
|
115
127
|
after_save
|
128
|
+
|
129
|
+
return true
|
130
|
+
end
|
131
|
+
|
132
|
+
def save!
|
133
|
+
result = self.save
|
134
|
+
|
135
|
+
if result != true
|
136
|
+
throw ValidationErrors.new(result)
|
137
|
+
end
|
138
|
+
|
139
|
+
return self
|
116
140
|
end
|
117
141
|
|
118
142
|
def before_delete
|
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.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: relaxo
|