class Qa::LDF::NamespacedSearchService

A search service that wraps another SearchService and casts its ids to a namespace.

@example

nsify = Qa::LDF::NamespacedSearchService.new do |service|
  service.namespace      = 'http://example.com/ns/'
  service.parent_service = a_search_service_instance
end

# when
a_search_service_endpoint.search('moomin') # => { 'id' => 'blah' }

# then
nsify.search('moomin') # => { 'id' => 'http://example.com/ns/blah' }

Attributes

namespace[RW]

@!attribute [rw] namespace

@return [String]

@!attribute [rw] parent_service

@return [#search]
parent_service[RW]

@!attribute [rw] namespace

@return [String]

@!attribute [rw] parent_service

@return [#search]

Public Class Methods

new() { |self| ... } click to toggle source

@yieldparam service [NamespacedSearchService] yields self

# File lib/qa/ldf/namespaced_search_service.rb, line 30
def initialize
  yield self
end

Public Instance Methods

apply_namespace(id) click to toggle source
# File lib/qa/ldf/namespaced_search_service.rb, line 50
def apply_namespace(id)
  return id if RDF::URI(id).valid?
  (RDF::URI(namespace) / id).to_s
end