Class: OracleSqlParser::Ast::Identifier

Inherits:
Hash show all
Defined in:
lib/oracle-sql-parser/ast/identifier.rb

Instance Method Summary collapse

Methods inherited from Hash

[], #[]=, #initialize, #map_ast!, #method_missing, #remove_nil_values!

Methods inherited from Base

#==, [], #ast, #deep_dup, deep_dup, find_different_value, #initialize, #initialize_copy, #map_ast, #map_ast!, #remove_nil_values!

Methods included from Util::Parameterizable

#to_parameterized, #to_parameternized

Constructor Details

This class inherits a constructor from OracleSqlParser::Ast::Hash

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OracleSqlParser::Ast::Hash

Instance Method Details

#inspectObject



3
4
5
# File 'lib/oracle-sql-parser/ast/identifier.rb', line 3

def inspect
  "#<#{self.class.name} #{@ast.inspect}>"
end

#quoted?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/oracle-sql-parser/ast/identifier.rb', line 7

def quoted?
  @ast[:quoted] == true
end

#to_sql(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/oracle-sql-parser/ast/identifier.rb', line 11

def to_sql(options = {})
  result = []
  if quoted?
    result << "\"#{@ast[:name]}\""
  else
    result << @ast[:name]
  end
  result << @ast[:as] if @ast[:as]
  result << @ast[:alias] if @ast[:alias]
  result.map(&:to_sql).join(' ')
end