object_attorney 2.2.10 → 2.2.11
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
|
-
|
|
4
|
+
ZDNjNTU1NmM2MDhkZmIwODRlMjE1ZjhmMmRiYzI5ODFlMzFlZDIxMg==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
MjQ0NGYyYjg1NmRhMzY1NGVjZGFiZGYzODk1NGQyMTJjMWJkMzFhNg==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
NTMyNDA4MDY3N2UyZDJmMDgxNzU5OWQ1N2JhNWZlOWRiN2Q2YzE1MDg2MTQ4
|
|
10
|
+
OGMzNmE0ZTgwZjEyNzc2YjU4ZjFjOWI0ODEzYzdiMDNmODI4N2VlYjI3NDk3
|
|
11
|
+
ZWNmYTc0MmRkODdmYzFhNTEzOTM1MzdkNTM0OGQ0NWViODg1ZGU=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
ZmZhZmRmZjNlODA1YzkyMzQ5MzcyNGQzODRkNWM3ZTZlNjJkN2JkZTdkOWFl
|
|
14
|
+
ZDdhZDc2ZjcyYzdiMDc4ODkxZjdiZWI0MjNhODljNWYyOTRlOTMwMzdkMDk2
|
|
15
|
+
NzlkOTc3NGI0NDkxNTBjYjVhYzdhNjJiZGVlYWY0N2EyMTg3YmY=
|
|
@@ -7,6 +7,11 @@ module ObjectAttorney
|
|
|
7
7
|
def is_integer?(string)
|
|
8
8
|
string.match(/^(\d)+$/)
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
def singularize(class_name)
|
|
12
|
+
class_name = class_name.to_s
|
|
13
|
+
plural?(class_name) ? class_name.singularize : class_name
|
|
14
|
+
end
|
|
10
15
|
|
|
11
16
|
def plural?(string)
|
|
12
17
|
string = string.to_s
|
|
@@ -126,7 +126,7 @@ module ObjectAttorney
|
|
|
126
126
|
nested_object.assign_attributes(attributes_without_destroy(attributes))
|
|
127
127
|
mark_for_destruction_if_necessary(nested_object, attributes)
|
|
128
128
|
else
|
|
129
|
-
nested_object = send("build_#{
|
|
129
|
+
nested_object = send("build_#{Helpers.singularize(nested_object_name)}", attributes_without_destroy(attributes))
|
|
130
130
|
mark_for_destruction_if_necessary(nested_object, attributes)
|
|
131
131
|
end
|
|
132
132
|
|
|
@@ -157,7 +157,7 @@ module ObjectAttorney
|
|
|
157
157
|
(send("#{nested_object_name}_attributes") || {}).values.each do |attributes|
|
|
158
158
|
next if attributes["id"].present? || attributes[:id].present?
|
|
159
159
|
|
|
160
|
-
new_nested_object = send("build_#{
|
|
160
|
+
new_nested_object = send("build_#{Helpers.singularize(nested_object_name)}", attributes_without_destroy(attributes))
|
|
161
161
|
next unless new_nested_object
|
|
162
162
|
|
|
163
163
|
mark_for_destruction_if_necessary(new_nested_object, attributes)
|
|
@@ -18,7 +18,7 @@ module ObjectAttorney
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def single_name
|
|
21
|
-
@single_name ||= options[:single_name] ||
|
|
21
|
+
@single_name ||= options[:single_name] || Helpers.singularize(name)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def plural_name
|
|
@@ -27,11 +27,6 @@ module ObjectAttorney
|
|
|
27
27
|
|
|
28
28
|
private ################################# private
|
|
29
29
|
|
|
30
|
-
def single_name_default
|
|
31
|
-
class_name = name.to_s
|
|
32
|
-
Helpers.plural?(class_name) ? class_name.singularize : class_name
|
|
33
|
-
end
|
|
34
|
-
|
|
35
30
|
def klass_default(class_name)
|
|
36
31
|
if Helpers.plural?(class_name)
|
|
37
32
|
class_name.to_s.singularize.camelize
|