Class: RDF::AllegroGraph::Query::PrologLiteral

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

Overview

A literal value which can be passed as an argument to a Prolog functor.

See Also:

  • @FunctorExpression

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ PrologLiteral

Constract a new Prolog literal.



9
10
11
# File 'lib/rdf/allegro_graph/query/prolog_literal.rb', line 9

def initialize(value)
  @value = value
end

Instance Method Details

#to_sString

Serialize this literal as a string. We need to be careful about security here: Our callers might try to pass in untrustworthy values without thinking through the consequences, and we want to limit the damage. We assume that all symbols are trustworthy.



19
20
21
22
23
24
25
26
27
# File 'lib/rdf/allegro_graph/query/prolog_literal.rb', line 19

def to_s
  case @value
  when Symbol, Numeric
    @value.to_s
  else
    err = "Don't know how to serialize #{@value.inspect} securely"
    raise ArgumentError.new(err)
  end
end