Module: ParenthesisedNode

Defined in:
lib/sql_munger/nodes.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args, &block) ⇒ Object

this is actually def value, but it mustn’t override the value methods for the literal nodes.



233
234
235
236
237
238
239
# File 'lib/sql_munger/nodes.rb', line 233

def method_missing( symbol, *args, &block )
  if symbol == :value
    parenthesised_value
  else
    super
  end
end

Instance Method Details

#parenthesised_valueObject

this will end up being called for anything that’s not handled by one of the XXXLiteralNode modules. Right now it basically applies to function calls only.



244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/sql_munger/nodes.rb', line 244

def parenthesised_value
  node = self
  while node.respond_to?( :parenthesised ) && !node.respond_to?( :function )
    node = node.parenthesised
  end
  
  unless node == self
    node.value
  else
    text_value
  end
end