lib/piglet/field/infix_expression.rb in piglet-0.2.5 vs lib/piglet/field/infix_expression.rb in piglet-0.3.0

- old
+ new

@@ -13,27 +13,32 @@ if options[:type] @type = options[:type] else @type = determine_type(@left_expression, @right_expression) end + @predecessors = [left_expression, right_expression] end def simple? false end - def to_s - left = @left_expression - right = @right_expression + def to_s(inner=false) + if inner + left = @left_expression.field_alias + right = @right_expression.field_alias + else + left = @left_expression + right = @right_expression - if left.respond_to?(:operator) && left.operator != @operator - left = parenthesise(left) - end + if left.respond_to?(:operator) && left.operator != @operator + left = parenthesise(left) + end - if right.respond_to?(:operator) && right.operator != @operator - right = parenthesise(right) + if right.respond_to?(:operator) && right.operator != @operator + right = parenthesise(right) + end end - "#{left} #{@operator} #{right}" end private \ No newline at end of file