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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74d659b5ce62094b660fb044b328739bf1649063a995028f40ed2d6afc8bdf7c
4
- data.tar.gz: bc2c13187de339827dedb67bfa038c52b723b8696dfdfe29f1c68bf91d242f1a
3
+ metadata.gz: 781896d5b8cd0411b2415a8b9e7a33bd3c16ba735bbd6f4089110ed2157cacf6
4
+ data.tar.gz: bd0a051d4e305ac537ce868429e9da06dc2844e511593010f0bc8ec7c42079e1
5
5
  SHA512:
6
- metadata.gz: f39c7c0b7b7aca6f628fa455b5bf14bc2dec6dc19709779d107387538187e57d34be8c228ee59235d861866535c2738d2689d1457d6b6e7363e094370c800979
7
- data.tar.gz: e0148847feb9812a2e09eb34bd4051fa02768e17a52678a7a7a6d9b4777b957cab44a8e299dab3ed5ed5cf15a5557afbea2958b83767d58bb1b4c18b3e23a4d6
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
- (attribute_names + relationship_attributes).uniq
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 relationship_attributes.include?(attribute)
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
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Material
4
- VERSION = "0.3.11"
4
+ VERSION = "0.3.12"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: material
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Garside