Sha256: f09b666af247f3f43a0c3db4424ec820caff70c879bbab15ba4acf21e5e7a426

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

module RGeoServer
  # A namespace is a uniquely identifiable grouping of feature types. A namespaces is identified by a prefix and a uri.
  class Namespace < ResourceInfo

    OBJ_ATTRIBUTES = {:enabled => 'enabled', :catalog => 'catalog', :name => 'prefix', :uri => 'uri' }
    OBJ_DEFAULT_ATTRIBUTES = {:enabled => 'true', :catalog => nil, :name => nil }

    define_attribute_methods OBJ_ATTRIBUTES.keys
    update_attribute_accessors OBJ_ATTRIBUTES

    @@route = "namespaces"
    @@resource_name = "namespace"

    def self.resource_name
      @@resource_name
    end

    def self.root_xpath
      "//#{@@route}/#{@@resource_name}"
    end

    def self.member_xpath
      "//#{resource_name}"
    end

    def route
      @@route  
    end

    def message
      builder = Nokogiri::XML::Builder.new do |xml|
        xml.namespace { 
          xml.prefix @name 
          xml.uri @uri
        }
      end
      return builder.doc.to_xml 
    end

    # @param [RGeoServer::Catalog] catalog
    # @param [Hash] options
    def initialize catalog, options
      super({})
      _run_initialize_callbacks do
        @catalog = catalog
        @name = options[:name].strip
        @uri = options[:uri] if options[:uri]
      end        
      @route = route
    end

    def profile_xml_to_hash profile_xml
      doc = profile_xml_to_ng profile_xml 
      h = {
        'name' => doc.at_xpath('//namespace/prefix/text()').to_s,
        'uri' => doc.at_xpath('//namespace/uri/text()').to_s
      }.freeze
      h  
    end

  end
end 

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rgeoserver-0.5.9 lib/rgeoserver/namespace.rb
rgeoserver-0.5.8.2 lib/rgeoserver/namespace.rb
rgeoserver-0.5.8.1 lib/rgeoserver/namespace.rb
rgeoserver-0.5.8 lib/rgeoserver/namespace.rb
rgeoserver-0.5.7 lib/rgeoserver/namespace.rb