class Symgate::Metadata::Client

client for the Symgate metadata system

Public Instance Methods

destroy_metadata(scope, keys) click to toggle source

Destroys one or more metadata items on the specified scope, specified by their key(s). Specify a valid scope and a single string, or an array of strings.

# File lib/symgate/metadata/client.rb, line 51
def destroy_metadata(scope, keys)
  k = [keys].flatten
  check_array_for_type(k, String)
  raise Symgate::Error, 'No keys supplied' if k.empty?

  savon_request(:destroy_metadata, returns_error_string: true) do |soap|
    soap.message(scope: scope, key: k)
  end
end
get_metadata(opts = {}) click to toggle source

Gets metadata visible to the current user.

If the 'scope' option is specified, this will list only the metadata defined at a particular scope. Otherwise it will list metadata items visible, with user metadata replacing group metadata and so on.

If the 'keys' option is specified, this will list only the metadata matching the list of keys supplied.

The 'key' option is also provided as a convenience, which works as above for a single item.

# File lib/symgate/metadata/client.rb, line 20
def get_metadata(opts = {})
  o = opts
  parse_get_metadata_opts o
  o[:key] = o.delete(:keys) if o.include? :keys

  resp = savon_request(:get_metadata) { |soap| soap.message(o) }

  Symgate::Client.savon_array(
    resp.body[:get_metadata_response],
    :data_item,
    Symgate::Metadata::DataItem
  )
end
set_metadata(items) click to toggle source

Creates one or more metadata items, overwriting any that match the key and scope specified within the DataItem object. Supply either a single item or an array of items.

# File lib/symgate/metadata/client.rb, line 37
def set_metadata(items)
  i = [items].flatten

  check_array_for_type(i, Symgate::Metadata::DataItem)
  raise Symgate::Error, 'No items supplied' if i.empty?

  savon_request(:set_metadata, returns_error_string: true) do |soap|
    soap.message(:auth:data_item => i.map(&:to_soap))
  end
end

Private Instance Methods

parse_get_metadata_opts(opts) click to toggle source
# File lib/symgate/metadata/client.rb, line 63
def parse_get_metadata_opts(opts)
  arrayize_option(:key, :keys, opts)
  check_option_is_array_of(String, :keys, opts)
  check_for_unknown_opts(%i[keys scope], opts)
end