Class: Lutaml::Hal::Link
- Inherits:
-
Model::Serializable
- Object
- Model::Serializable
- Lutaml::Hal::Link
- Defined in:
- lib/lutaml/hal/link.rb
Overview
HAL Link representation with realization capability
Instance Attribute Summary collapse
-
#parent_resource ⇒ Object
Store reference to parent resource for automatic embedded content detection.
Instance Method Summary collapse
-
#realize(register: nil, parent_resource: nil) ⇒ Object
Fetch the actual resource this link points to.
Instance Attribute Details
#parent_resource ⇒ Object
Store reference to parent resource for automatic embedded content detection
15 16 17 |
# File 'lib/lutaml/hal/link.rb', line 15 def parent_resource @parent_resource end |
Instance Method Details
#realize(register: nil, parent_resource: nil) ⇒ Object
Fetch the actual resource this link points to. This method will use the global register according to the source of the Link object. If the Link does not have a register, a register needs to be provided explicitly via the ‘register:` parameter.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/lutaml/hal/link.rb', line 30 def realize(register: nil, parent_resource: nil) # Use provided parent_resource or fall back to stored parent_resource effective_parent = parent_resource || @parent_resource # First check if embedded content is available if effective_parent && ( = (effective_parent, register)) return end register = find_register(register) raise "No register provided for link resolution (class: #{self.class}, href: #{href})" if register.nil? Hal.debug_log "Resolving link href: #{href} using register" register.resolve_and_cast(self, href) end |