instructure-active_model-better_errors 1.6.3.rails2 → 1.6.3.rails2.1
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/VERSION +1 -1
- data/lib/active_model/error_collecting/emulation.rb +9 -7
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.3.rails2
|
1
|
+
1.6.3.rails2.1
|
@@ -30,21 +30,23 @@ module ActiveModel
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def add_on_empty(attributes, options = {})
|
33
|
-
[attributes].flatten.each do |
|
34
|
-
value = @base.send(:
|
33
|
+
[attributes].flatten.each do |attr|
|
34
|
+
value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) : @base[attr.to_s]
|
35
35
|
is_empty = value.respond_to?(:empty?) ? value.empty? : false
|
36
|
-
add(
|
36
|
+
add(attr, :empty, options) if value.nil? || is_empty
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
def add_on_blank(attributes, options = {})
|
41
|
-
[attributes].flatten.each do |
|
42
|
-
value = @base.send(:
|
43
|
-
add(
|
41
|
+
[attributes].flatten.each do |attr|
|
42
|
+
value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) : @base[attr.to_s]
|
43
|
+
add(attr, :blank, options) if value.blank?
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def add(attribute, message=nil, options =
|
47
|
+
def add(attribute, message=nil, options = nil)
|
48
|
+
options ||= {}
|
49
|
+
options = { message: options } unless options.is_a?(Hash)
|
48
50
|
if options[:strict]
|
49
51
|
error = ErrorMessage.build(attribute, message, options)
|
50
52
|
message = HumanMessageFormatter.new(@base, error).format_message
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instructure-active_model-better_errors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.3.rails2
|
4
|
+
version: 1.6.3.rails2.1
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -292,7 +292,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
292
292
|
version: '0'
|
293
293
|
segments:
|
294
294
|
- 0
|
295
|
-
hash:
|
295
|
+
hash: -329676681584185471
|
296
296
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
297
297
|
none: false
|
298
298
|
requirements:
|