object_attorney 2.5.0 → 2.5.2

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGMwYTYwMmZhY2E1MDNmYTk3ZTdmY2RmZmFiYThjZjRiYzkzN2FmYg==
4
+ ZWM4NWIwNTNjMjRmYzRiYzM1MTcxNWFkOTI1ZGQwY2ZhMDNmOTFjMA==
5
5
  data.tar.gz: !binary |-
6
- ZDczNTc0ZjcxNmM2NGQ0ZjU0MmI2OWFiMWUzZDZhMjVhYTEwMTY5Ng==
6
+ NTM3MGVmZGRjOGZhNWNmZjI1ZDc1MjEyYTExY2VhNDFhNjRkZDllOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWMzZTMyZDIwNjY1YzM2OTgzOTc3MWU1NzM2ZWJiZjBjN2FjOGUyMjY2NGUy
10
- Y2U1MjZjOTE5ZDA5ZjY3OTMyNDA5NjIyNGQzY2E3ZTE4Yzg3MThiYTlhZmQw
11
- ZTkxYTU4MzNjYTA4YjdkYjA5OWE0MDAzOWViOTZkNmQ1MTYxYmU=
9
+ OTllZDFkMDJiYjk1ZWRhMDI2MWQyYzBhYjkzMDk3YWFhMDM4MGIxYTY0NmZh
10
+ ZmQ2MTAzODY4NzU0YjZhYjZiYWIzMDY2ZGU3MDVhZWM4YjJlODg5ZDhiYTg1
11
+ ZTFlYTQ1Yjg3M2Q3Zjg2ODk2NTliYTAzMDY0NWJkMTdjZWE0NTE=
12
12
  data.tar.gz: !binary |-
13
- ZGFmMzQ0ZGM1NWUyMzFiYTYwYjRiYWRiYTcxNDhmZGQxMzVmZjFhMzU3N2Jm
14
- MGM4NDdlMzg2NWVjN2EzZTBiMTE4ZjM1ZjRmMjE2MTVlYzM4OWRjN2IwMjJl
15
- NjExZmE5MDQ5YTFjNzU3M2ZjY2FjNzM1ZGZlNTE0MzVkYjc2YTM=
13
+ OWM1Zjg4ZDY1NzIwMzhmYjA1MmRlOWIxYWE0NDI3MWEwMjE4YzZlYjZkNDg1
14
+ NGZlNDlhYzFiYjZmNTYzOTBiMTk0ZGQ4MzVhMjg1ZTU3NzE2OWU2MGZmZTBj
15
+ MmJhZDU0ZjEzZjVjNDZkZDY4NzM2NmIzYWYwYzhlZDBlZGI4MmI=
@@ -0,0 +1,32 @@
1
+ module ObjectAttorney
2
+
3
+ module AttributeAssignment
4
+
5
+ def assign_attributes(attributes = {})
6
+ return if attributes.blank?
7
+
8
+ attributes.each do |name, value|
9
+ send("#{name}=", value) if allowed_attribute(name)
10
+ end
11
+
12
+ mark_for_destruction_if_necessary(self, attributes)
13
+ end
14
+
15
+ protected #################### PROTECTED METHODS DOWN BELOW ######################
16
+
17
+ def parsing_arguments(attributes, object)
18
+ if !attributes.is_a?(Hash) && object.blank?
19
+ object = attributes
20
+ attributes = nil
21
+ end
22
+
23
+ attributes = {} if attributes.blank?
24
+ end
25
+
26
+ def allowed_attribute(attribute)
27
+ respond_to?("#{attribute}=")
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,19 @@
1
+ module ObjectAttorney
2
+
3
+ module Delegation
4
+
5
+ def zuper_method(method_name, *args)
6
+ self.superclass.send(method_name, *args) if self.superclass.respond_to?(method_name)
7
+ end
8
+
9
+ def delegate_properties(*properties, options)
10
+ properties.each { |property| delegate_property(property, options) }
11
+ end
12
+
13
+ def delegate_property(property, options)
14
+ delegate property, "#{property}=", options
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,16 @@
1
+ module ObjectAttorney
2
+
3
+ module Naming
4
+
5
+ def model_name
6
+ @_model_name ||= begin
7
+ namespace = self.parents.detect do |n|
8
+ n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
9
+ end
10
+ ActiveModel::Name.new(represented_object_class || self, namespace)
11
+ end
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -55,13 +55,7 @@ module ObjectAttorney
55
55
  end
56
56
 
57
57
  def validate_nested_objects
58
- valid = nested_objects.map do |reflection, nested_object|
59
- nested_object.marked_for_destruction? ? true : nested_object.valid?
60
- end.all?
61
-
62
- import_nested_objects_errors unless valid
63
-
64
- valid
58
+ nested_objects.map { |reflection, nested_object| nested_object.valid? }.all?
65
59
  end
66
60
 
67
61
  def import_nested_objects_errors
@@ -111,9 +105,7 @@ module ObjectAttorney
111
105
  nested_instance_variable = reflection.has_many? ? get_existing_and_new_nested_objects(nested_object_name) : get_existing_or_new_nested_object(nested_object_name)
112
106
 
113
107
  [*nested_instance_variable].each do |nested_object|
114
- nested_object.extend(ImportedErrors)
115
-
116
- # nested_object.singleton_class.validate(:validate_imported_errors)
108
+ nested_object.extend(Validations) unless nested_object.respond_to?(:represented_object)
117
109
  end
118
110
 
119
111
  self.instance_variable_set("@#{nested_object_name}", nested_instance_variable)
@@ -1,5 +1,6 @@
1
1
  module ObjectAttorney
2
- module ORM
2
+
3
+ module Record
3
4
 
4
5
  def id
5
6
  represented_object.try(:id)
@@ -43,36 +44,34 @@ module ObjectAttorney
43
44
  end
44
45
  end
45
46
 
46
- def clear_nested_imported_errors
47
+ def clear_nested_imposed_errors
47
48
  nested_objects.each do |reflection, nested_object|
48
- nested_object.clear_imported_errors
49
+ nested_object.clear_imposed_errors
49
50
 
50
- nested_object.clear_nested_imported_errors if nested_object.respond_to?(:clear_nested_imported_errors)
51
+ nested_object.clear_nested_imposed_errors if nested_object.respond_to?(:clear_nested_imposed_errors)
51
52
  end
52
53
  end
53
54
 
54
- def populate_nested_imported_errors
55
+ def populate_nested_imposed_errors
55
56
  nested_objects.each do |reflection, nested_object|
56
57
  next if nested_object.marked_for_destruction?
57
58
 
58
- nested_object.populate_imported_errors
59
+ nested_object.populate_imposed_errors
59
60
 
60
- nested_object.populate_nested_imported_errors if nested_object.respond_to?(:populate_nested_imported_errors)
61
+ nested_object.populate_nested_imposed_errors if nested_object.respond_to?(:populate_nested_imposed_errors)
61
62
  end
62
63
  end
63
64
 
64
65
  protected #################### PROTECTED METHODS DOWN BELOW ######################
65
66
 
66
67
  def save_or_!
67
- clear_imported_errors
68
-
69
- clear_imported_errors
70
- clear_nested_imported_errors
68
+ clear_imposed_errors
69
+ clear_nested_imposed_errors
71
70
 
72
71
  save_result = valid? ? yield : false
73
72
 
74
- populate_imported_errors
75
- populate_nested_imported_errors
73
+ populate_imposed_errors
74
+ populate_nested_imposed_errors
76
75
 
77
76
  after_save if valid? && save_result
78
77
 
@@ -114,4 +113,5 @@ module ObjectAttorney
114
113
  end
115
114
 
116
115
  end
116
+
117
117
  end
@@ -0,0 +1,90 @@
1
+ module ObjectAttorney
2
+
3
+ module Representation
4
+
5
+ def read_attribute_for_serialization(attribute)
6
+ respond_to?(attribute) ? send(attribute) : nil
7
+ end
8
+
9
+ def send_to_representative(method_name, *args)
10
+ return false if represented_object.blank?
11
+
12
+ represented_object.send(method_name, *args)
13
+ end
14
+
15
+ def represented_object
16
+ @represented_object ||= self.class.represented_object_class.try(:new)
17
+ end
18
+
19
+ protected #################### PROTECTED METHODS DOWN BELOW ######################
20
+
21
+ def validate_represented_object
22
+ represented_object_valid = Helpers.try_or_return(represented_object, :valid?, true)
23
+
24
+ load_errors_from represented_object.errors unless represented_object_valid
25
+
26
+ nested_valid = add_errors_entry_if_nested_invalid
27
+
28
+ represented_object_valid && nested_valid
29
+ end
30
+
31
+ private #################### PRIVATE METHODS DOWN BELOW ######################
32
+
33
+ def add_errors_entry_if_nested_invalid
34
+ nested_vs_invalid = {}
35
+
36
+ nested_objects.each do |reflection, nested_object|
37
+ if !nested_object.errors.empty? && !nested_vs_invalid.include?(reflection.name)
38
+ message = errors.send(:normalize_message, reflection.name, :invalid, {})
39
+
40
+ if !errors.messages[reflection.name].try(:include?, message)
41
+ nested_vs_invalid[reflection.name] = message
42
+ end
43
+ end
44
+ end
45
+
46
+ load_errors_from nested_vs_invalid
47
+
48
+ nested_vs_invalid.empty?
49
+ end
50
+
51
+ def self.included(base)
52
+ base.extend(ClassMethods)
53
+ end
54
+
55
+ module ClassMethods
56
+
57
+ def represents(represented_object_name, options = {})
58
+ self.instance_variable_set("@represented_object_reflection", Reflection.new(represented_object_name, options))
59
+
60
+ define_method(represented_object_name) { represented_object }
61
+
62
+ delegate_properties(*options[:properties], to: represented_object_name) if options.include?(:properties)
63
+
64
+ delegate(*options[:readers], to: represented_object_name) if options.include?(:readers)
65
+
66
+ if options.include?(:writers)
67
+ writers = options[:writers].map { |writer| "#{writer}=" }
68
+ delegate(*writers, to: represented_object_name)
69
+ end
70
+ end
71
+
72
+ def represented_object_reflection
73
+ self.instance_variable_get("@represented_object_reflection") || zuper_method('represented_object_reflection')
74
+ end
75
+
76
+ def represented_object_class
77
+ represented_object_reflection.try(:klass)
78
+ end
79
+
80
+ def represented_object_reflect_on_association(association)
81
+ return nil if represented_object_class.nil?
82
+
83
+ represented_object_class.reflect_on_association(association)
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+
90
+ end
@@ -0,0 +1,25 @@
1
+ module ObjectAttorney
2
+
3
+ module Translation
4
+
5
+ def human_attribute_name(attribute_key_name, options = {})
6
+ no_translation = "-- no translation --"
7
+
8
+ defaults = ["object_attorney.attributes.#{name.underscore}.#{attribute_key_name}".to_sym]
9
+ defaults << options[:default] if options[:default]
10
+ defaults.flatten!
11
+ defaults << no_translation
12
+ options[:count] ||= 1
13
+
14
+ translation = I18n.translate(defaults.shift, options.merge(default: defaults))
15
+
16
+ if translation == no_translation && represented_object_class.respond_to?(:human_attribute_name)
17
+ translation = represented_object_class.human_attribute_name(attribute_key_name, options)
18
+ end
19
+
20
+ translation
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,42 @@
1
+ module ObjectAttorney
2
+ module Validations
3
+
4
+ def valid?(context = nil)
5
+ return true if override_validations?
6
+
7
+ context ||= (new_record? ? :create : :update)
8
+ output = super(context)
9
+
10
+ load_errors_from imposed_errors
11
+
12
+ errors.empty? && output
13
+ end
14
+
15
+ def override_validations?
16
+ marked_for_destruction?
17
+ end
18
+
19
+ def clear_imposed_errors
20
+ @imposed_errors = {}
21
+ end
22
+
23
+ def populate_imposed_errors
24
+ if respond_to?(:represented_object)
25
+ represented_object.errors.each { |key, value| @imposed_errors[key] = value } if represented_object.present?
26
+ else
27
+ errors.each { |key, value| @imposed_errors[key] = value }
28
+ end
29
+ end
30
+
31
+ def imposed_errors
32
+ @imposed_errors ||= {}
33
+ end
34
+
35
+ private #################### PRIVATE METHODS DOWN BELOW ######################
36
+
37
+ def load_errors_from(errors)
38
+ errors.each { |key, value| self.errors.add(key, value) }
39
+ end
40
+
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module ObjectAttorney
2
- VERSION = "2.5.0"
2
+ VERSION = "2.5.2"
3
3
  end
@@ -1,71 +1,39 @@
1
- require "object_attorney/version"
1
+
2
+ require "object_attorney/attribute_assignment"
3
+ require "object_attorney/delegation"
2
4
  require "object_attorney/helpers"
5
+ require "object_attorney/naming"
3
6
  require "object_attorney/reflection"
4
- require "object_attorney/imported_errors"
7
+ require "object_attorney/validations"
5
8
  require "object_attorney/nested_objects"
6
- require "object_attorney/orm"
9
+ require "object_attorney/record"
10
+ require "object_attorney/translation"
11
+ require "object_attorney/representation"
7
12
  require 'active_record'
8
13
 
14
+ require "object_attorney/version"
15
+
9
16
  module ObjectAttorney
10
17
 
11
18
  def initialize(attributes = {}, object = nil)
12
19
  initialize_nested_attributes
13
20
 
14
- if !attributes.is_a?(Hash) && object.blank?
15
- object = attributes
16
- attributes = nil
17
- end
21
+ parsing_arguments(attributes, object)
18
22
 
19
23
  before_initialize(attributes)
20
24
 
21
- attributes = {} if attributes.blank?
22
-
23
- @represented_object = object if object.present?
25
+ @represented_object = object
24
26
 
25
27
  assign_attributes attributes
26
- mark_for_destruction_if_necessary(self, attributes)
27
28
 
28
29
  after_initialize(attributes)
29
30
  end
30
31
 
31
- def assign_attributes(attributes = {})
32
- return if attributes.blank?
33
-
34
- attributes.each do |name, value|
35
- send("#{name}=", value) if allowed_attribute(name)
36
- end
37
- end
38
-
39
- def read_attribute_for_serialization(attribute)
40
- respond_to?(attribute) ? send(attribute) : nil
41
- end
42
-
43
- def send_to_representative(method_name, *args)
44
- return false if represented_object.blank?
45
-
46
- represented_object.send(method_name, *args)
47
- end
48
-
49
32
  protected #################### PROTECTED METHODS DOWN BELOW ######################
50
33
 
51
34
  def before_initialize(attributes); end
52
- def after_initialize(attributes); end
53
-
54
- def allowed_attribute(attribute)
55
- respond_to?("#{attribute}=")
56
- end
57
-
58
- def validate_represented_object
59
- valid = override_validations? ? true : Helpers.try_or_return(represented_object, :valid?, true)
60
-
61
- incorporate_errors_from(represented_object.errors) unless valid
62
35
 
63
- valid
64
- end
65
-
66
- def represented_object
67
- @represented_object ||= self.class.represented_object_class.try(:new)
68
- end
36
+ def after_initialize(attributes); end
69
37
 
70
38
  private #################### PRIVATE METHODS DOWN BELOW ######################
71
39
 
@@ -74,95 +42,23 @@ module ObjectAttorney
74
42
  include ActiveModel::Validations
75
43
  include ActiveModel::Validations::Callbacks
76
44
  include ActiveModel::Conversion
77
- include ObjectAttorney::ImportedErrors
78
- include ObjectAttorney::NestedObjects
79
- include ObjectAttorney::ORM
80
45
 
81
- validate :validate_represented_object
82
- validate :validate_imported_errors
46
+ include AttributeAssignment
47
+ include Validations
48
+ include NestedObjects
49
+ include Record
50
+ include Translation
51
+ include Representation
83
52
 
84
- def valid?(context = nil)
85
- override_validations? ? true : super(context)
86
- end
53
+ validate :validate_represented_object
87
54
  end
88
55
 
89
56
  base.extend(ClassMethods)
90
57
  end
91
58
 
92
- def override_validations?
93
- marked_for_destruction?
94
- end
95
-
96
59
  module ClassMethods
97
-
98
- def represents(represented_object_name, options = {})
99
- self.instance_variable_set("@represented_object_reflection", Reflection.new(represented_object_name, options))
100
-
101
- define_method(represented_object_name) { represented_object }
102
-
103
- delegate_properties(*options[:properties], to: represented_object_name) if options.include?(:properties)
104
-
105
- delegate(*options[:readers], to: represented_object_name) if options.include?(:readers)
106
-
107
- if options.include?(:writers)
108
- writers = options[:writers].map { |writer| "#{writer}=" }
109
- delegate(*writers, to: represented_object_name)
110
- end
111
- end
112
-
113
- def represented_object_reflection
114
- self.instance_variable_get("@represented_object_reflection") || zuper_method('represented_object_reflection')
115
- end
116
-
117
- def represented_object_class
118
- represented_object_reflection.try(:klass)
119
- end
120
-
121
- def represented_object_reflect_on_association(association)
122
- return nil if represented_object_class.nil?
123
-
124
- represented_object_class.reflect_on_association(association)
125
- end
126
-
127
- def zuper_method(method_name, *args)
128
- self.superclass.send(method_name, *args) if self.superclass.respond_to?(method_name)
129
- end
130
-
131
- def delegate_properties(*properties, options)
132
- properties.each { |property| delegate_property(property, options) }
133
- end
134
-
135
- def delegate_property(property, options)
136
- delegate property, "#{property}=", options
137
- end
138
-
139
- def human_attribute_name(attribute_key_name, options = {})
140
- no_translation = "-- no translation --"
141
-
142
- defaults = ["object_attorney.attributes.#{name.underscore}.#{attribute_key_name}".to_sym]
143
- defaults << options[:default] if options[:default]
144
- defaults.flatten!
145
- defaults << no_translation
146
- options[:count] ||= 1
147
-
148
- translation = I18n.translate(defaults.shift, options.merge(default: defaults))
149
-
150
- if translation == no_translation && represented_object_class.respond_to?(:human_attribute_name)
151
- translation = represented_object_class.human_attribute_name(attribute_key_name, options)
152
- end
153
-
154
- translation
155
- end
156
-
157
- def model_name
158
- @_model_name ||= begin
159
- namespace = self.parents.detect do |n|
160
- n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
161
- end
162
- ActiveModel::Name.new(represented_object_class || self, namespace)
163
- end
164
- end
165
-
60
+ include Naming
61
+ include Delegation
166
62
  end
167
63
 
168
64
  end
@@ -74,7 +74,7 @@ shared_examples "a BulkPostsWithFormObjectsForm" do
74
74
  bulk_posts_form = described_class.new(params[:bulk_post])
75
75
  bulk_posts_form.save
76
76
 
77
- bulk_posts_form.should have(2).errors_on(:posts)
77
+ bulk_posts_form.should have(1).errors_on(:posts)
78
78
  bulk_posts_form.posts.first.should have(1).errors_on(:title)
79
79
  bulk_posts_form.posts.second.should have(:no).errors_on(:title)
80
80
  bulk_posts_form.posts.third.should have(1).errors_on(:title)
@@ -2,19 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe PostValidationsForm do
4
4
 
5
- it "asd", current: true do
6
- post1 = Post.new
7
- post1.valid?.should == true
8
-
9
- post1.singleton_class.validates_presence_of :title
10
- # binding.pry
11
- post1.valid?.should == false
12
-
13
- post2 = Post.new
14
- post2.valid?.should == true
15
- end
16
-
17
- it "1. 'PostValidationsForm' becomes invalid if 'Post' has errors after the #submit method and incorporates its errors." do
5
+ it "1. 'PostValidationsForm' becomes invalid if 'Post' has errors after the #submit method and incorporates its errors.", current: true do
18
6
  params = {
19
7
  post: {
20
8
  title: 'First post',
@@ -31,22 +19,26 @@ describe PostValidationsForm do
31
19
  post_form.save
32
20
 
33
21
  post_form.should have(1).error_on(:title)
22
+ post_form.should have(1).error_on(:comments)
34
23
  post_form.errors.size.should == 2
35
24
  post_form.comments.first.should have(1).error_on(:body)
36
25
 
37
26
  post_form.valid?.should == false
38
27
  post_form.should have(1).error_on(:title)
28
+ post_form.should have(1).error_on(:comments)
39
29
  post_form.errors.size.should == 2
40
30
  post_form.comments.first.should have(1).error_on(:body)
41
31
 
42
32
  post_form.save
43
33
 
44
34
  post_form.should have(1).error_on(:title)
35
+ post_form.should have(1).error_on(:comments)
45
36
  post_form.errors.size.should == 2
46
37
  post_form.comments.first.should have(1).error_on(:body)
47
38
 
48
39
  post_form.valid?.should == false
49
40
  post_form.should have(1).error_on(:title)
41
+ post_form.should have(1).error_on(:comments)
50
42
  post_form.errors.size.should == 2
51
43
  post_form.comments.first.should have(1).error_on(:body)
52
44
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe PostWithCommentValidationsForm do
4
4
 
5
- it "1. 'PostWithCommentValidationsForm' becomes invalid if 'Post' or nested 'Comment's has errors after the #submit method and incorporates its errors." do
5
+ it "1. 'PostWithCommentValidationsForm' becomes invalid if 'Post' or nested 'Comment's has errors after the #submit method and incorporates its errors.", current: true do
6
6
  params = {
7
7
  post: {
8
8
  title: 'First post',
@@ -19,22 +19,26 @@ describe PostWithCommentValidationsForm do
19
19
  post_form.save
20
20
 
21
21
  post_form.should have(1).error_on(:title)
22
+ post_form.should have(1).error_on(:comments)
22
23
  post_form.errors.size.should == 2
23
24
  post_form.comments.first.should have(1).error_on(:body)
24
25
 
25
26
  post_form.valid?.should == false
26
27
  post_form.should have(1).error_on(:title)
28
+ post_form.should have(1).error_on(:comments)
27
29
  post_form.errors.size.should == 2
28
30
  post_form.comments.first.should have(1).error_on(:body)
29
31
 
30
32
  post_form.save
31
33
 
32
34
  post_form.should have(1).error_on(:title)
35
+ post_form.should have(1).error_on(:comments)
33
36
  post_form.errors.size.should == 2
34
37
  post_form.comments.first.should have(1).error_on(:body)
35
38
 
36
39
  post_form.valid?.should == false
37
40
  post_form.should have(1).error_on(:title)
41
+ post_form.should have(1).error_on(:comments)
38
42
  post_form.errors.size.should == 2
39
43
  post_form.comments.first.should have(1).error_on(:body)
40
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_attorney
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Gonçalves
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-09 00:00:00.000000000 Z
11
+ date: 2014-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,14 +74,19 @@ files:
74
74
  - db/schema.rb
75
75
  - lib/object_attorney.rb
76
76
  - lib/object_attorney/association_reflection.rb
77
+ - lib/object_attorney/attribute_assignment.rb
78
+ - lib/object_attorney/delegation.rb
77
79
  - lib/object_attorney/helpers.rb
78
- - lib/object_attorney/imported_errors.rb
80
+ - lib/object_attorney/naming.rb
79
81
  - lib/object_attorney/nested_objects.rb
80
- - lib/object_attorney/nested_uniqueness_validator.rb
81
- - lib/object_attorney/orm.rb
82
82
  - lib/object_attorney/orm_handlers/smooth_operator.rb
83
+ - lib/object_attorney/record.rb
83
84
  - lib/object_attorney/reflection.rb
85
+ - lib/object_attorney/representation.rb
86
+ - lib/object_attorney/translation.rb
87
+ - lib/object_attorney/validations.rb
84
88
  - lib/object_attorney/version.rb
89
+ - not_used/nested_uniqueness_validator.rb
85
90
  - object_attorney.gemspec
86
91
  - spec/object_attorney/bulk_post_form_spec.rb
87
92
  - spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb
@@ -1,33 +0,0 @@
1
- module ObjectAttorney
2
- module ImportedErrors
3
-
4
- protected #################### PROTECTED METHODS DOWN BELOW ######################
5
-
6
- def clear_imported_errors
7
- @imported_errors = {}
8
- end
9
-
10
- def populate_imported_errors
11
- if respond_to?(:represented_object)
12
- represented_object.errors.each { |key, value| @imported_errors[key] = value } if represented_object.present?
13
- else
14
- errors.each { |key, value| @imported_errors[key] = value }
15
- end
16
- end
17
-
18
- def validate_imported_errors
19
- imported_errors = (@imported_errors || {})
20
-
21
- incorporate_errors_from imported_errors
22
-
23
- imported_errors.empty?
24
- end
25
-
26
- private #################### PRIVATE METHODS DOWN BELOW ######################
27
-
28
- def incorporate_errors_from(errors)
29
- errors.each { |key, value| self.errors.add(key, value) }
30
- end
31
-
32
- end
33
- end