Class: AllegroGraph::Proxy::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/allegro_graph/proxy/query.rb

Overview

The Query class acts as proxy that bypasses SparQL and Prolog queries to the AllegroGraph server.

Constant Summary collapse

LANGUAGES =
[ :sparql, :prolog ].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ Query

Returns a new instance of Query.



15
16
17
18
# File 'lib/allegro_graph/proxy/query.rb', line 15

def initialize(resource)
  @resource = resource
  @language = :sparql
end

Instance Attribute Details

#languageObject

Returns the value of attribute language.



13
14
15
# File 'lib/allegro_graph/proxy/query.rb', line 13

def language
  @language
end

#resourceObject (readonly)

Returns the value of attribute resource.



12
13
14
# File 'lib/allegro_graph/proxy/query.rb', line 12

def resource
  @resource
end

#serverObject (readonly)

Returns the value of attribute server.



11
12
13
# File 'lib/allegro_graph/proxy/query.rb', line 11

def server
  @server
end

Instance Method Details

#pathObject



20
21
22
# File 'lib/allegro_graph/proxy/query.rb', line 20

def path
  @resource.path
end

#perform(query) ⇒ Object



30
31
32
33
# File 'lib/allegro_graph/proxy/query.rb', line 30

def perform(query)
  parameters = { :query => query, :queryLn => @language.to_s }
  @resource.request_json :get, self.path, :parameters => parameters, :expected_status_code => 200
end