module SDL::Base::DefaultURIMapper

Simple implementation of a default URI mapper.

Constants

DEFAULT_BASE_URI

Public Class Methods

uri(object) click to toggle source
# File lib/sdl/base/default_uri_mapper.rb, line 7
def self.uri(object)
  case object
    when Type.class
      "#{DEFAULT_BASE_URI}/types/#{object.local_name}"
    when Type::Service
      "#{DEFAULT_BASE_URI}/services/#{object.identifier}"
    when Type
      if object.identifier
        "#{object.class.uri}/#{object.identifier.to_s}"
      else
        "#{object.parent.uri}/#{object.class.local_name}/#{object.parent_index}"
      end
    else
      raise "Cannot infer URI of object: #{object}"
  end
end