Module: VORuby::Resources

Defined in:
lib/voruby/resources/stsci.rb,
lib/voruby/resources/loader.rb,
lib/voruby/resources/sia/sia.rb,
lib/voruby/resources/sia/sia_v0_6.rb,
lib/voruby/resources/sia/sia_v0_7.rb,
lib/voruby/resources/sia/sia_v1_0.rb,
lib/voruby/resources/conesearch/conesearch.rb,
lib/voruby/resources/voregistry/voregistry.rb,
lib/voruby/resources/voresource/voresource.rb,
lib/voruby/resources/openskynode/openskynode.rb,
lib/voruby/resources/conesearch/conesearch_v0_2.rb,
lib/voruby/resources/conesearch/conesearch_v0_3.rb,
lib/voruby/resources/conesearch/conesearch_v1_0.rb,
lib/voruby/resources/voregistry/voregistry_v0_2.rb,
lib/voruby/resources/voregistry/voregistry_v0_3.rb,
lib/voruby/resources/voregistry/voregistry_v1_0.rb,
lib/voruby/resources/voresource/voresource_v0_9.rb,
lib/voruby/resources/voresource/voresource_v1_0.rb,
lib/voruby/resources/vodataservice/coverage_v0_2.rb,
lib/voruby/resources/vodataservice/coverage_v0_3.rb,
lib/voruby/resources/vodataservice/vodataservice.rb,
lib/voruby/resources/voresource/voresource_v0_10.rb,
lib/voruby/resources/openskynode/openskynode_v0_1.rb,
lib/voruby/resources/vodataservice/vodataservice_v0_4.rb,
lib/voruby/resources/vodataservice/vodataservice_v0_5.rb,
lib/voruby/resources/vodataservice/vodataservice_v1_0.rb

Defined Under Namespace

Modules: ConeSearch, OpenSkyNode, SIA, STScI, VODataService, VODataServiceCoverage, VORegistry, VOResource

Constant Summary collapse

NAMESPACE_MODULE_MAP =
{ 
  'http://www.ivoa.net/xml/VOResource/v0.10' => 'VORuby::Resources::VOResource::V_10',
  'http://www.ivoa.net/xml/VOResource/v0.9' => 'VORuby::Resources::VOResource::V0_9',
  'http://www.ivoa.net/xml/VOResource/v1.0' => 'VORuby::Resources::VOResource::V1_0',
  'http://www.ivoa.net/xml/VODataService/v0.4' => 'VORuby::Resources::VODataService',
  'http://www.ivoa.net/xml/VODataService/v0.5' => 'VORuby::Resources::VODataService::V0_5',
  'http://www.ivoa.net/xml/VODataService/v1.0' => 'VORuby::Resources::VODataService::V1_0',
  'http://www.ivoa.net/xml/OpenSkyNode/v0.1' => 'VORuby::OpenSkyNode',
  'http://www.ivoa.net/xml/VORegistry/v0.2' => 'VORuby::Resources::VORegistry::V0_2',
  'http://www.ivoa.net/xml/VORegistry/v0.3' => 'VORuby::Resources::VORegistry::V0_3',
  'http://www.ivoa.net/xml/VORegistry/v1.0' => 'VORuby::Resources::VORegistry::V1_0',
  'http://www.ivoa.net/xml/SIA/v0.6' => 'VORuby::Resources::SIA::V0_6',
  'http://www.ivoa.net/xml/SIA/v0.7' => 'VORuby::Resources::SIA::V0_7',
  'http://www.ivoa.net/xml/SIA/v1.0' => 'VORuby::Resources::SIA::V1_0',
  'http://www.ivoa.net/xml/ConeSearch/v0.2' => 'VORuby::Resources::ConeSearch::V0_2',
  'http://www.ivoa.net/xml/ConeSearch/v0.3' => 'VORuby::Resources::ConeSearch::V0_3',
  'http://www.ivoa.net/xml/ConeSearch/v1.0' => 'VORuby::Resources::ConeSearch::V1_0'
}

Class Method Summary collapse

Class Method Details

.namespace_dispatcher(default_module, default_type, default_class) ⇒ Object

Dynamically dispatches a request to a class using the determined XML namespace.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/voruby/resources/loader.rb', line 27

def self.namespace_dispatcher(default_module, default_type, default_class)
  return Proc.new{ |xml|
    the_module = type = nil
    if xml.attributes['type']
      ns_prefix, type = xml.attributes['type'].split(':')
      type = ns_prefix if !type

      the_module = NAMESPACE_MODULE_MAP[xml.namespace(ns_prefix)]
      the_module = default_module if !the_module
    else
      the_module = default_module
      type = default_type
    end

    # The name of the appropriate class corresponds to the type.
    begin
      eval("#{the_module}::#{type}.load_from_xml(xml)") # Would like to get rid of this eval somehow...
    rescue NameError
      default_class.load_from_xml(xml)
    end
  }
end