material 0.3.11 → 0.3.12
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 +4 -4
- data/lib/material/concerns/attributes.rb +20 -2
- data/lib/material/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 781896d5b8cd0411b2415a8b9e7a33bd3c16ba735bbd6f4089110ed2157cacf6
|
4
|
+
data.tar.gz: bd0a051d4e305ac537ce868429e9da06dc2844e511593010f0bc8ec7c42079e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 132790c6c0245bb722d579dfd77e1c4136649ff060577fcd9dded434622c433dd6bc2e16f58c2d0ed9f0f027190b77e92ddafa5e6cf3289d48e2a66fba2ca7f5
|
7
|
+
data.tar.gz: ac24f93e23d6f5a4f750194033ec7648415b94d9272ac3c5602b27e28410b45357207d0b2d9654c728facda821b4507a5f81888fb50f74d92b696c2a0b14e834
|
@@ -12,6 +12,7 @@ module Material
|
|
12
12
|
memoize :formatted_attributes
|
13
13
|
memoize :sorted_attribute_names
|
14
14
|
memoize :relationship_attributes
|
15
|
+
memoize :unique_display_attributes
|
15
16
|
end
|
16
17
|
|
17
18
|
class_methods do
|
@@ -29,7 +30,23 @@ module Material
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def display_attributes
|
32
|
-
|
33
|
+
unique_display_attributes
|
34
|
+
end
|
35
|
+
|
36
|
+
def unique_display_attributes
|
37
|
+
[].tap do |attrs|
|
38
|
+
attribute_names.each do |attribute_name|
|
39
|
+
next if relationship_attribute?(attribute_name)
|
40
|
+
|
41
|
+
attrs << attribute_name
|
42
|
+
end
|
43
|
+
|
44
|
+
attrs.concat(relationship_attributes).uniq
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def relationship_attribute?(attribute_name)
|
49
|
+
relationship_attributes.include?(attribute_name) || relationship_attributes.include?(attribute_name.chomp("_id"))
|
33
50
|
end
|
34
51
|
|
35
52
|
def attribute_values
|
@@ -42,7 +59,7 @@ module Material
|
|
42
59
|
|
43
60
|
def formatted_attributes
|
44
61
|
attribute_types.each_with_object({}) do |(attribute, attribute_type), hash|
|
45
|
-
next if
|
62
|
+
next if relationship_attribute?(attribute)
|
46
63
|
hash[attribute] = format_by_type(attribute_values[attribute], type: attribute_type)
|
47
64
|
end
|
48
65
|
end
|
@@ -60,3 +77,4 @@ module Material
|
|
60
77
|
end
|
61
78
|
end
|
62
79
|
end
|
80
|
+
|
data/lib/material/version.rb
CHANGED