lutaml-hal 0.1.8 → 0.1.9

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: 754c6e7a5a61e4b96398c511a8e5f0e7dd721dab154272b5de4ce580fc204f71
4
- data.tar.gz: fa3c07d2deed3ddf2605da05a375412eb2222273c46c7f3338982b5b99e1fefb
3
+ metadata.gz: 3193d7b68f48f5930b5247d0b962ed31fc39f5280b171084bd1ef36ffd2ff6b5
4
+ data.tar.gz: 8cc11026dfbe93ab84546cf2e358d8a14fd9e71acef677675201bf1e288bdcb2
5
5
  SHA512:
6
- metadata.gz: 6aff2792a51f0467f5dd470de4656f8630046bbbe741120dbf54b75cf3120b57c8771a1e300b2790be2cc5bca53beebdda86a28085c3b2e8025c993d49ffc3ea
7
- data.tar.gz: 62886f1267ac6119302234a750258882d9a4e4fce0ad24ad9b6c1b2a7ea89876df8cffe33def528aed4a95d33a69f9e0157f8b84c45c23eff36b5f4a47942a01
6
+ metadata.gz: 87f583829974459e7edbeadfa3a4bca22b616a7e2b02afba0171159728c612265a1147dc7a32ac4677e798eec1129377b3bcba74ce8f24262590c5ac060453e7
7
+ data.tar.gz: 46e96d2f8d1ca38a7c71d48280046d2765749acc19877b2628305d7de4c6949dbcb0512933343ea68453d44e052ac6553d18e051839d23cb50d17fbb6075ece3
data/README.adoc CHANGED
@@ -126,7 +126,7 @@ For detailed documentation, see these comprehensive guides:
126
126
  URL patterns and path matching examples
127
127
 
128
128
  * **link:docs/embedded-resources.adoc[Embedded resources]** - Implementing and
129
- using embedded resources in HAL APIs
129
+ using embedded resources in HAL APIs with automatic link realization
130
130
 
131
131
 
132
132
  === Architecture overview
@@ -11,6 +11,9 @@ module Lutaml
11
11
  # will be used to resolve unless overriden in resource#realize()
12
12
  attr_accessor Hal::REGISTER_ID_ATTR_NAME.to_sym
13
13
 
14
+ # Store reference to parent resource for automatic embedded content detection
15
+ attr_accessor :parent_resource
16
+
14
17
  attribute :href, :string
15
18
  attribute :title, :string
16
19
  attribute :name, :string
@@ -25,8 +28,11 @@ module Lutaml
25
28
  # If the Link does not have a register, a register needs to be provided explicitly
26
29
  # via the `register:` parameter.
27
30
  def realize(register: nil, parent_resource: nil)
31
+ # Use provided parent_resource or fall back to stored parent_resource
32
+ effective_parent = parent_resource || @parent_resource
33
+
28
34
  # First check if embedded content is available
29
- if parent_resource && (embedded_content = check_embedded_content(parent_resource, register))
35
+ if effective_parent && (embedded_content = check_embedded_content(effective_parent, register))
30
36
  return embedded_content
31
37
  end
32
38
 
@@ -134,7 +134,12 @@ module Lutaml
134
134
 
135
135
  # Handle both array and single values with the same logic
136
136
  values = value.is_a?(Array) ? value : [value]
137
- values.each { |item| mark_model_links_with_register(item) }
137
+ values.each do |item|
138
+ mark_model_links_with_register(item)
139
+
140
+ # If this is a Link, set the parent resource for automatic embedded content detection
141
+ item.parent_resource = inspecting_model if item.is_a?(Lutaml::Hal::Link)
142
+ end
138
143
  end
139
144
 
140
145
  inspecting_model
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Hal
5
- VERSION = '0.1.8'
5
+ VERSION = '0.1.9'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-hal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.