relaxo-model 0.4.7 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50e7a5fa856f14fdbc7873bfc8fde8eb7acc225c
4
- data.tar.gz: 62fefc6d1ebb388be91ab5a4ea6446454bf87e21
3
+ metadata.gz: ed8c070f4630e99c32c46328cab4ced85740c870
4
+ data.tar.gz: 2b48dbeb94ae7e9a445c37f4b98d9e935066f54c
5
5
  SHA512:
6
- metadata.gz: 41ce9a6692a28b927994a1a334d451c27a89bbc4ff3badc6e56c9e8256c5aa7ad8db3fa1322bbee3136831efbb71b14023c3c11c7c4a2b5cc41cd73885edc0c5
7
- data.tar.gz: fdec6be6efdc34f0a264bbfd88c52af8796ca91e805e47c08cf600e1267977932e0ef1596a5850a7f59e6ec6689537aa0f38bc9cff813dfcfd59acd5f211a18d
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
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Relaxo
22
22
  module Model
23
- VERSION = "0.4.7"
23
+ VERSION = "0.4.8"
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.4.7
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-09 00:00:00.000000000 Z
11
+ date: 2016-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaxo