Method: RDF::Query::Variable#bind

Defined in:
lib/rdf/query/variable.rb

#bind(value) ⇒ self #bind(value) ⇒ RDF::Term Also known as: bind!

Rebinds this variable to the given ‘value`.

Overloads:

  • #bind(value) ⇒ self

    Returns the bound variable.

    Parameters:

    Returns:

    • (self)

      the bound variable

  • #bind(value) ⇒ RDF::Term

    Returns the previous value, if any.

    Parameters:

    Returns:

    • (RDF::Term)

      the previous value, if any.

Since:

  • 0.3.0



181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/rdf/query/variable.rb', line 181

def bind(value)
  if value.is_a?(RDF::Query::Solution)
    self.value = value.to_h.fetch(name, self.value)
    self
  else
    warn "[DEPRECATION] RDF::Query::Variable#bind should be used with a solution, not a term.\n" +
         "Called from #{Gem.location_of_caller.join(':')}"
    old_value = self.value
    self.value = value
    old_value
  end
end