class Lutaml::Hal::ModelRegister
def resolve_and_cast(link, href)
def resolve_and_cast(link, href) raise 'Client not configured' unless client Hal.debug_log("resolve_and_cast: link #{link}, href #{href}") response = client.get_by_url(href) # TODO: Merge full Link content into the resource? response_with_link_details = response.to_h.merge({ 'href' => href }) href_path = href.sub(client.api_url, '') model_class = find_matching_model_class(href_path) raise LinkResolutionError, "Unregistered URL pattern: #{href}" unless model_class Hal.debug_log("resolve_and_cast: resolved to model_class #{model_class}") Hal.debug_log("resolve_and_cast: response: #{response.inspect}") Hal.debug_log("resolve_and_cast: amended: #{response_with_link_details}") model = model_class.from_json(response_with_link_details.to_json) mark_model_links_with_register(model) model end