lib/sparql/algebra/expression.rb in sparql-1.1.6 vs lib/sparql/algebra/expression.rb in sparql-1.1.7
- old
+ new
@@ -118,11 +118,11 @@
else raise TypeError, "invalid SPARQL::Algebra::Expression operand: #{operand.inspect}"
end
end
debug(options) {"#{operator.inspect}(#{operands.map(&:inspect).join(',')})"}
- options.delete_if {|k, v| [:debug, :depth, :prefixes, :base_uri, :update].include?(k) }
+ options.delete_if {|k, v| [:debug, :depth, :prefixes, :base_uri, :update, :validate].include?(k) }
operands << options unless options.empty?
operator.new(*operands)
end
##
@@ -315,10 +315,36 @@
# @return [Array] `self`
# @see http://openjena.org/wiki/SSE
def to_sxp_bin
self
end
-
+
+ ##
+ # Is this value valid, and composed only of valid components?
+ #
+ # @return [Boolean] `true` or `false`
+ def valid?
+ true
+ end
+
+ ##
+ # Is this value invalid, or is it composed of any invalid components?
+ #
+ # @return [Boolean] `true` or `false`
+ def invalid?
+ !valid?
+ end
+
+ ##
+ # Default validate! implementation, overridden in concrete classes
+ # @return [SPARQL::Algebra::Expression] `self`
+ # @raise [ArgumentError] if the value is invalid
+ def validate!
+ raise ArgumentError if invalid?
+ self
+ end
+ alias_method :validate, :validate!
+
private
# @overload: May be called with node, message and an option hash
# @param [String] node processing node
# @param [String] message
# @param [Hash{Symbol => Object}] options