Class: SqlMunger::TableName
- Inherits:
-
Object
- Object
- SqlMunger::TableName
- Includes:
- Quoter
- Defined in:
- lib/sql_munger/table_name.rb
Overview
Essentially a qualified table name that’s parsed and makes the parts accessible. TODO reduce dependency on Treetop and parser.
Instance Attribute Summary collapse
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Attributes included from Quoter
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(qualified_identifier, quoter = nil) ⇒ TableName
constructor
A new instance of TableName.
- #name ⇒ Object
- #parts ⇒ Object
- #quote ⇒ Object
- #to_s ⇒ Object
Methods included from Quoter
#identifier_quoter, included, #value_quoter
Constructor Details
#initialize(qualified_identifier, quoter = nil) ⇒ TableName
Returns a new instance of TableName.
12 13 14 15 16 |
# File 'lib/sql_munger/table_name.rb', line 12 def initialize( qualified_identifier, quoter = nil ) @quoter = quoter @qualified_identifier = qualified_identifier @tree = self.class.sql_parser.parse( @qualified_identifier ) end |
Instance Attribute Details
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
18 19 20 |
# File 'lib/sql_munger/table_name.rb', line 18 def tree @tree end |
Class Method Details
Instance Method Details
#name ⇒ Object
28 29 30 |
# File 'lib/sql_munger/table_name.rb', line 28 def name @tree.parts.last end |
#parts ⇒ Object
32 33 34 |
# File 'lib/sql_munger/table_name.rb', line 32 def parts @tree.parts end |
#quote ⇒ Object
36 37 38 39 40 |
# File 'lib/sql_munger/table_name.rb', line 36 def quote parts.map do |part| quoter.quote_ident( part ) end.join('.') end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/sql_munger/table_name.rb', line 42 def to_s @tree.parts.join( '.' ) end |