err_supply 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module ErrSupply
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -71,13 +71,16 @@ module ErrSupply
71
71
  #---------------------------------------------
72
72
  # apply options to children
73
73
  #---------------------------------------------
74
-
74
+
75
+ # get keys
75
76
  assoc_names = errors.keys.map { |k| k.to_s.split(".") }.select { |a| a.many? }.map { |a| a[0] }.compact.uniq
76
77
 
78
+ # if child has errors or is invalid (i.e., we prefer explicitly declared errrors),
79
+ # call function recursively and merge results
77
80
  assoc_names.each do |assoc_name|
78
81
  c_options = options[assoc_name.to_sym] || {}
79
82
  obj.send("#{assoc_name}").each_with_index do |child, index|
80
- unless child.valid?
83
+ if !child.errors.empty? or child.invalid?
81
84
  c_prefix = "#{prefix}_#{assoc_name}_attributes_#{index}"
82
85
  c_hash = err_supply_hash(child, c_options.merge({ :prefix => c_prefix }))
83
86
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: err_supply
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 8
10
- version: 0.0.8
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Coroutine
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-06-22 00:00:00 -05:00
19
+ date: 2011-09-28 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency