Module: ActiveSesame::SesameProtocol

Defined in:
lib/active_sesame/repository.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



61
62
63
# File 'lib/active_sesame/repository.rb', line 61

def self.extended(klass)
  simple_rest_methods :size, :contexts, :namespaces
end

.simple_rest_methods(*method_names) ⇒ Object



75
76
77
78
79
80
# File 'lib/active_sesame/repository.rb', line 75

def self.simple_rest_methods(*method_names)
  method_names.each do |name|
    new_name = name.to_s
    define_method(new_name) { return query_dispatch(name) }
  end
end

Instance Method Details

#query_dispatch(method_name, args = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
# File 'lib/active_sesame/repository.rb', line 65

def query_dispatch(method_name, args={})
  args[:body][:query] = encode_sparql(args[:body][:query]) if args[:body][:query] if args[:body]
  args[:body][:subj] = encode_sparql(args[:body][:subj]) if args[:body][:subj] if args[:body]
  args[:body][:pred] = encode_sparql(args[:body][:pred]) if args[:body][:pred] if args[:body]
  args[:body][:obj] = encode_sparql(args[:body][:obj]) if args[:body][:obj] if args[:body]
  [:get, :put, :delete].include?(args[:method]) ? vars_if_get = hash_to_get(args[:body]) : vars_if_get = ""
  method_name == "" ? slash = "" : slash = "/"
  return open(self.repository_uri + "/" + self.triple_store_id + slash + method_name.to_s + vars_if_get, args).read
end