ratatouille 1.4.2 → 1.4.3
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.
- data/CHANGELOG.md +6 -0
- data/lib/ratatouille/hash.rb +1 -1
- data/lib/ratatouille/ratifier.rb +9 -9
- data/lib/ratatouille/version.rb +1 -1
- data/spec/lib/ratatouille/ratifier_spec.rb +0 -6
- metadata +3 -3
data/CHANGELOG.md
CHANGED
data/lib/ratatouille/hash.rb
CHANGED
data/lib/ratatouille/ratifier.rb
CHANGED
@@ -40,7 +40,7 @@ module Ratatouille
|
|
40
40
|
# @return [String]
|
41
41
|
def name
|
42
42
|
@name ||= @ratifiable_object.class.to_s
|
43
|
-
end
|
43
|
+
end#name
|
44
44
|
|
45
45
|
|
46
46
|
# Set name of instance
|
@@ -53,22 +53,22 @@ module Ratatouille
|
|
53
53
|
@name = namein unless namein.blank?
|
54
54
|
end
|
55
55
|
@name
|
56
|
-
end
|
56
|
+
end#name=
|
57
57
|
|
58
58
|
|
59
59
|
# Add validation error. Useful for custom validations.
|
60
60
|
# @param [String] err_in
|
61
61
|
# @param [String] context
|
62
62
|
# @return [void]
|
63
|
-
def validation_error(err_in, context="/")
|
63
|
+
def validation_error(err_in, context="/" )
|
64
64
|
case err_in
|
65
65
|
when String
|
66
66
|
return if err_in.blank?
|
67
67
|
@errors[context] = [] unless @errors[context]
|
68
|
-
@errors[context] <<
|
68
|
+
@errors[context] << err_in
|
69
69
|
end
|
70
70
|
rescue Exception => e
|
71
|
-
@errors[
|
71
|
+
@errors[context] << "#{e.message}"
|
72
72
|
end#validation_error
|
73
73
|
|
74
74
|
|
@@ -104,7 +104,7 @@ module Ratatouille
|
|
104
104
|
else []
|
105
105
|
end
|
106
106
|
|
107
|
-
all_errs << namespace_error_array(item_errs, "
|
107
|
+
all_errs << namespace_error_array(item_errs, "#{i}")
|
108
108
|
all_errs.flatten!
|
109
109
|
end
|
110
110
|
when Hash
|
@@ -159,7 +159,7 @@ module Ratatouille
|
|
159
159
|
when TrueClass, FalseClass
|
160
160
|
# OK to enter block
|
161
161
|
else
|
162
|
-
validation_error("
|
162
|
+
validation_error("#{name} is not a boolean")
|
163
163
|
return
|
164
164
|
end
|
165
165
|
end
|
@@ -204,14 +204,14 @@ module Ratatouille
|
|
204
204
|
when id.to_s =~ /^is_not_(.*)$/
|
205
205
|
if @ratifiable_object.respond_to?("#{$1}?")
|
206
206
|
if @ratifiable_object.send("#{$1}?") == true
|
207
|
-
validation_error("is #{$1}")
|
207
|
+
validation_error("#{name} is #{$1}")
|
208
208
|
return
|
209
209
|
end
|
210
210
|
end
|
211
211
|
when id.to_s =~ /^is_(.*)$/
|
212
212
|
if @ratifiable_object.respond_to?("#{$1}?")
|
213
213
|
if @ratifiable_object.send("#{$1}?") == false
|
214
|
-
validation_error("is not #{$1}")
|
214
|
+
validation_error("#{name} is not #{$1}")
|
215
215
|
return
|
216
216
|
end
|
217
217
|
end
|
data/lib/ratatouille/version.rb
CHANGED
@@ -77,12 +77,6 @@ describe Ratatouille::Ratifier do
|
|
77
77
|
validation_error("some error")
|
78
78
|
end
|
79
79
|
test.errors_array.should have(1).String
|
80
|
-
|
81
|
-
test = RatifierTest.new({}) do
|
82
|
-
validation_error("some error")
|
83
|
-
validation_error("another error")
|
84
|
-
end
|
85
|
-
test.errors_array.should have(2).String
|
86
80
|
end
|
87
81
|
|
88
82
|
it "should not create an error when called with a non-string argument" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratatouille
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 3
|
10
|
+
version: 1.4.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Johnson
|