standardapi 1.0.14 → 1.0.15

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
  SHA1:
3
- metadata.gz: bae8ab8cb0e9504d2a04105b232912be7d2e800d
4
- data.tar.gz: 0685d8c1c8cde8f423bc29b20443226297090814
3
+ metadata.gz: f892bfaae15d0e0561eedcf89269ff98d18f2044
4
+ data.tar.gz: c9e734b482f12719dae0b6da8d384aadf64ac02c
5
5
  SHA512:
6
- metadata.gz: 3c677a3aea24f4d7f1409fd149571954a705bdc50d163131be72fe27602c85d9554498b194ad0c4635fdeb55d1b9fb91c87d96edc166630eb608f808c8827053
7
- data.tar.gz: 0bf6e349cd22b92126e6d0fc15057299b36ad296349618496755bce7d1c1ff09a2f8269eba65d93781ecff74d752556c317b2b18f294706e04fd936f19ecf471
6
+ metadata.gz: 3c749360b6a4ceb688dbb0914bccf1c0d4680304a682e1fd57bd7a221552a8731ae3c93fd5f15de2ea6f4f46ae0c1101cc8ca652392553d795799e1f9d873061
7
+ data.tar.gz: 548a8a618e9769b88ba0bab84e921ab0fdd4e36a8c04b3f7cc8958f1927c3e689c29b512f6398402e247363ed4b5090e4c5a7840ef9282c794516ae0d8541e68
data/README.md CHANGED
@@ -15,7 +15,7 @@ API access to, or in the ApplicationController, giving all inherited controller
15
15
  access.
16
16
 
17
17
  class ApplicationController < ActiveController::Base
18
- include StandardAPI
18
+ include StandardAPI::Controller
19
19
 
20
20
  end
21
21
 
@@ -79,10 +79,20 @@ module StandardAPI
79
79
  end
80
80
  else
81
81
  m = assigns(:record).send(included).first.try(:reload)
82
+
83
+ m_json = if m && m.has_attribute?(:id)
84
+ json[included.to_s].find { |x| x['id'] == normalize_to_json(m, :id, m.id) }
85
+ elsif m
86
+ json[included.to_s].find { |x| x.keys.all? { |key| x[key] == normalize_to_json(m, key, m[key]) } }
87
+ else
88
+ nil
89
+ end
90
+
82
91
  view_attributes(m).each do |key, value|
83
92
  message = "Model / Attribute: #{m.class.name}##{key}"
84
- assert_equal normalize_to_json(m, key, value), json[included.to_s][0][key.to_s], message
93
+ assert_equal m_json[key.to_s], normalize_to_json(m, key, value)
85
94
  end
95
+
86
96
  end
87
97
  end
88
98
  end
@@ -56,10 +56,20 @@ module StandardAPI
56
56
  end
57
57
  else
58
58
  m = assigns(:records).first.send(included).first.try(:reload)
59
+
60
+ m_json = if m && m.has_attribute?(:id)
61
+ json[included.to_s].find { |x| x['id'] == normalize_to_json(m, :id, m.id) }
62
+ elsif m
63
+ json[included.to_s].find { |x| x.keys.all? { |key| x[key] == normalize_to_json(m, key, m[key]) } }
64
+ else
65
+ nil
66
+ end
67
+
59
68
  view_attributes(m).each do |key, value|
60
69
  message = "Model / Attribute: #{m.class.name}##{key}"
61
- assert_equal json[included.to_s][0][key.to_s], normalize_to_json(m, key, value), message
70
+ assert_equal m_json[key.to_s], normalize_to_json(m, key, value)
62
71
  end
72
+
63
73
  end
64
74
  end
65
75
  end
@@ -30,10 +30,20 @@ module StandardAPI
30
30
  end
31
31
  else
32
32
  m = assigns(:record).send(included).first.try(:reload)
33
+
34
+ m_json = if m && m.has_attribute?(:id)
35
+ json[included.to_s].find { |x| x['id'] == normalize_to_json(m, :id, m.id) }
36
+ elsif m
37
+ json[included.to_s].find { |x| x.keys.all? { |key| x[key] == normalize_to_json(m, key, m[key]) } }
38
+ else
39
+ nil
40
+ end
41
+
33
42
  view_attributes(m).each do |key, value|
34
43
  message = "Model / Attribute: #{m.class.name}##{key}"
35
- assert_equal normalize_to_json(m, key, value), json[included.to_s][0][key.to_s], message
44
+ assert_equal m_json[key.to_s], normalize_to_json(m, key, value)
36
45
  end
46
+
37
47
  end
38
48
  end
39
49
  end
@@ -65,10 +65,19 @@ module StandardAPI
65
65
  end
66
66
  else
67
67
  m = assigns(:record).send(included).first.try(:reload)
68
+ m_json = if m && m.has_attribute?(:id)
69
+ json[included.to_s].find { |x| x['id'] == normalize_to_json(m, :id, m.id) }
70
+ elsif m
71
+ json[included.to_s].find { |x| x.keys.all? { |key| x[key] == normalize_to_json(m, key, m[key]) } }
72
+ else
73
+ nil
74
+ end
75
+
68
76
  view_attributes(m).each do |key, value|
69
77
  message = "Model / Attribute: #{m.class.name}##{key}"
70
- assert_equal normalize_to_json(assigns(:record), key, value), json[included.to_s][0][key.to_s], message
78
+ assert_equal m_json[key.to_s], normalize_to_json(m, key, value)
71
79
  end
80
+
72
81
  end
73
82
  end
74
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standardapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Bracy