Class: LUSI::API::Core::Code

Inherits:
BasicCode show all
Defined in:
lib/lusi_api/core/code.rb

Overview

Represents a LUSI code definition which can be retrieved through the LUSI API

Instance Attribute Summary

Attributes inherited from BasicCode

#description, #identity

Class Method Summary collapse

Methods inherited from BasicCode

#initialize, #to_s

Constructor Details

This class inherits a constructor from LUSI::API::Core::BasicCode

Class Method Details

.get_instance(api = nil, lookup = nil, path = nil, endpoint = nil, method = nil, xml_root = nil, **kwargs) {|obj| ... } ⇒ Array<LUSI::API::Core::Code>

Returns a Code instance for the specifiec LUSI API call

Parameters:

  • api (LUSI:API::Core::API) (defaults to: nil)

    the LUSI API instance

  • lookup (LUSI::API::Core::Lookup::LookupService, nil) (defaults to: nil)

    the lookup service for object resolution

  • path (String) (defaults to: nil)

    the LUSI API URL path

  • endpoint (String) (defaults to: nil)

    the LUSI API URL endpoint

  • method (String) (defaults to: nil)

    the LUSI API method

  • xml_root (String) (defaults to: nil)

    the XPath of the root element in the LUSI API response

  • identity (any)

    the identity to search for

  • description (String, nil)

    the description to search for

Yields:

  • (obj)

    Passes the Code instance to the block

Yield Parameters:

Returns:



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/lusi_api/core/code.rb', line 69

def self.get_instance(api = nil, lookup = nil, path = nil, endpoint = nil, method = nil, xml_root = nil, **kwargs)
  params = get_instance_params(**kwargs)
  xml = api.call(path, endpoint, method, **params)
  LUSI::API::Core::XML.xml(xml, xml_root) do |c|
    obj = new(c, lookup)
    begin
      yield(obj) if block_given?
    rescue StandardError => e
      puts e
    end
    obj
  end
end