lib/marc/spec/queries/condition_context.rb in ruby-marc-spec-0.1.2 vs lib/marc/spec/queries/condition_context.rb in ruby-marc-spec-0.1.3

- old
+ new

@@ -13,29 +13,24 @@ @context_result = context_result @executor = executor end def operand_value(operand, implicit: false) - return context_result if implicit && operand.nil? + return operand_value(context_result) if implicit && operand.nil? raw_value = operand_value_raw(operand) is_boolean = [true, false].include?(raw_value) is_boolean ? raw_value : as_string(raw_value) end private def operand_value_raw(operand) - return unless operand + return operand.str_exact if operand.is_a?(ComparisonString) + return operand.met?(self) if operand.is_a?(Condition) + return operand.execute(executor, [context_field], context_result) if operand.is_a?(Query) - case operand - when ComparisonString - operand.str_exact - when Condition - operand.met?(self) - when Query - operand.execute(executor, [context_field], context_result) - end + operand end def as_string(op_val) return unless op_val return op_val if op_val.is_a?(String)