hal-client 1.4.0 → 1.5.0
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/hal_client/representation.rb +13 -2
- data/lib/hal_client/version.rb +1 -1
- data/spec/hal_client/representation_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035b9a77a60897b009604c5b84b767f6870e9da7
|
4
|
+
data.tar.gz: 453668c1af155925f62572cfb8988b79cf9f302c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39f9c20f48fdf12774fa26ed087dd6a725d3c555b0d3f6741c5e23f65237f98414fea058c0113309105d017065edc257e28cebf88542acc1706e764160ebff1e
|
7
|
+
data.tar.gz: 0a2b994966d7427b4167934ca553264ce1a008d4a63b7385cc23d0f50340a52e7b32a035a39aa082ba0c05a0cb27dc7405c0ee3c1f79ce0eedf2e0d639489d72
|
@@ -111,10 +111,21 @@ class HalClient
|
|
111
111
|
fetch(item_key, nil)
|
112
112
|
end
|
113
113
|
|
114
|
+
# Returns true if this representation contains a link (including
|
115
|
+
# embedded links) whose rel is `link_rel`.
|
116
|
+
#
|
117
|
+
# link_rel - The link rel of interest
|
118
|
+
def has_related?(link_rel)
|
119
|
+
_ = related link_rel
|
120
|
+
true
|
121
|
+
rescue KeyError
|
122
|
+
false
|
123
|
+
end
|
124
|
+
|
114
125
|
# Returns representations of resources related via the specified
|
115
126
|
# link rel or the specified default value.
|
116
127
|
#
|
117
|
-
#
|
128
|
+
# link_rel - The link rel of interest
|
118
129
|
# options - optional keys and values with which to expand any
|
119
130
|
# templated links that are encountered
|
120
131
|
# default_proc - an option proc that will be called with `name`
|
@@ -141,7 +152,7 @@ class HalClient
|
|
141
152
|
# Returns urls of resources related via the specified
|
142
153
|
# link rel or the specified default value.
|
143
154
|
#
|
144
|
-
#
|
155
|
+
# link_rel - The link rel of interest
|
145
156
|
# options - optional keys and values with which to expand any
|
146
157
|
# templated links that are encountered
|
147
158
|
# default_proc - an option proc that will be called with `name`
|
data/lib/hal_client/version.rb
CHANGED
@@ -152,6 +152,11 @@ HAL
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
+
specify { expect(subject.has_related? "link1").to be true }
|
156
|
+
specify { expect(subject.has_related? "embed1").to be true }
|
157
|
+
|
158
|
+
specify { expect(subject.has_related? "no-such-link").to be false }
|
159
|
+
specify { expect(subject.has_related? "no-such-embed").to be false }
|
155
160
|
|
156
161
|
context "curie links" do
|
157
162
|
let(:raw_repr) { <<-HAL }
|
@@ -209,6 +214,7 @@ HAL
|
|
209
214
|
|
210
215
|
|
211
216
|
|
217
|
+
|
212
218
|
let(:a_client) { HalClient.new }
|
213
219
|
let!(:bar_request) { stub_identity_request("http://example.com/bar") }
|
214
220
|
let!(:baz_request) { stub_identity_request "http://example.com/baz" }
|