modelish 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +2 -0
- data/lib/modelish/validations.rb +2 -5
- data/lib/modelish/version.rb +1 -1
- metadata +6 -7
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.2.3 (2012-8-17)
|
4
|
+
|
5
|
+
* Tweak implementation of validate! method to call validate method, replacing a parallel
|
6
|
+
implementation that called individual property validators.
|
7
|
+
|
3
8
|
## 0.2.2 (2012-3-8)
|
4
9
|
|
5
10
|
* Minor bug fix in Modelish::Base#initialize to prevent modification of argument hash
|
data/README.md
CHANGED
@@ -98,6 +98,8 @@ Validations can be run using methods that return an error map (keyed on property
|
|
98
98
|
invalid_bar.validate!
|
99
99
|
# ArgumentError: important_field must not be nil or blank
|
100
100
|
|
101
|
+
In order to implement more complex validations that cannot be accomplished through simple property-specific validators, you may override the `validate` method. The `validate!` and `valid?` methods will continue to work as expected, as long as the overridden `validate` fulfills the contract (returning a hash keyed on property name, with values being arrays of error objects).
|
102
|
+
|
101
103
|
## Configuration ##
|
102
104
|
|
103
105
|
By default, modelish will raise an error when it encounters unknown property names in an initialization hash. If you'd prefer modelish to ignore unknown properties, you can override this default behavior for all of your modelish models:
|
data/lib/modelish/validations.rb
CHANGED
@@ -26,11 +26,8 @@ module Modelish
|
|
26
26
|
#
|
27
27
|
# @raise ArgumentError when any property fails validation
|
28
28
|
def validate!
|
29
|
-
|
30
|
-
|
31
|
-
raise error if error
|
32
|
-
end
|
33
|
-
nil
|
29
|
+
errors = validate
|
30
|
+
raise validate.first[1].first unless validate.empty?
|
34
31
|
end
|
35
32
|
|
36
33
|
def valid?
|
data/lib/modelish/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modelish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Maeve Revels
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
19
|
-
default_executable:
|
18
|
+
date: 2012-08-17 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: hashie
|
@@ -118,7 +117,6 @@ files:
|
|
118
117
|
- spec/support/typed_property_examples.rb
|
119
118
|
- spec/support/unknown_property_examples.rb
|
120
119
|
- spec/support/validation_examples.rb
|
121
|
-
has_rdoc: true
|
122
120
|
homepage: http://github.com/maeve/modelish
|
123
121
|
licenses: []
|
124
122
|
|
@@ -148,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
146
|
requirements: []
|
149
147
|
|
150
148
|
rubyforge_project: modelish
|
151
|
-
rubygems_version: 1.
|
149
|
+
rubygems_version: 1.8.24
|
152
150
|
signing_key:
|
153
151
|
specification_version: 3
|
154
152
|
summary: A lightweight pseudo-modeling not-quite-framework
|
@@ -164,3 +162,4 @@ test_files:
|
|
164
162
|
- spec/support/typed_property_examples.rb
|
165
163
|
- spec/support/unknown_property_examples.rb
|
166
164
|
- spec/support/validation_examples.rb
|
165
|
+
has_rdoc: true
|