Module: SDL::Base::DefaultURIMapper

Defined in:
lib/sdl/base/default_uri_mapper.rb

Overview

Simple implementation of a default URI mapper.

Constant Summary collapse

DEFAULT_BASE_URI =
'http://www.open-service-compendium.org'

Class Method Summary collapse

Class Method Details

.uri(object) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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