Class: ActiveRecord::ConnectionAdapters::SQLServer::Utils::Name
- Inherits:
 - 
      Object
      
        
- Object
 - ActiveRecord::ConnectionAdapters::SQLServer::Utils::Name
 
 
- Defined in:
 - lib/active_record/connection_adapters/sqlserver/utils.rb
 
Overview
Value object to return identifiers from SQL Server names bit.ly/1CZ3EiL Inspiried from Rails PostgreSQL::Name adapter object in their own Utils.
Constant Summary collapse
- SEPARATOR =
 "."- UNQUOTED_SCANNER =
 /\]?\./- QUOTED_SCANNER =
 /\A\[.*?\]\./- QUOTED_CHECKER =
 /\A\[/
Instance Attribute Summary collapse
- 
  
    
      #database  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute database.
 - 
  
    
      #object  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute object.
 - 
  
    
      #raw_name  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute raw_name.
 - 
  
    
      #schema  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute schema.
 - 
  
    
      #server  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute server.
 
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
 - #database_quoted ⇒ Object
 - #fully_qualified? ⇒ Boolean
 - #fully_qualified_database_quoted ⇒ Object
 - #hash ⇒ Object
 - 
  
    
      #initialize(name)  ⇒ Name 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Name.
 - #object_quoted ⇒ Object
 - #qualified_level ⇒ Object
 - #quoted ⇒ Object
 - #quoted_raw ⇒ Object
 - #schema_quoted ⇒ Object
 - #server_quoted ⇒ Object
 - #to_s ⇒ Object
 
Constructor Details
#initialize(name) ⇒ Name
Returns a new instance of Name.
      23 24 25 26  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 23 def initialize(name) @raw_name = name.to_s parse_raw_name end  | 
  
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
      20 21 22  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 20 def database @database end  | 
  
#object ⇒ Object (readonly)
Returns the value of attribute object.
      20 21 22  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 20 def object @object end  | 
  
#raw_name ⇒ Object (readonly)
Returns the value of attribute raw_name.
      21 22 23  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 21 def raw_name @raw_name end  | 
  
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
      20 21 22  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 20 def schema @schema end  | 
  
#server ⇒ Object (readonly)
Returns the value of attribute server.
      20 21 22  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 20 def server @server end  | 
  
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
      79 80 81  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 79 def ==(other) other.class == self.class && other.parts == parts end  | 
  
#database_quoted ⇒ Object
      36 37 38  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 36 def database_quoted database ? quote(database) : database end  | 
  
#fully_qualified? ⇒ Boolean
      48 49 50  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 48 def fully_qualified? qualified_level == :fully end  | 
  
#fully_qualified_database_quoted ⇒ Object
      44 45 46  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 44 def fully_qualified_database_quoted [server_quoted, database_quoted].compact.join(SEPARATOR) end  | 
  
#hash ⇒ Object
      84 85 86  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 84 def hash parts.hash end  | 
  
#object_quoted ⇒ Object
      28 29 30  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 28 def object_quoted quote object end  | 
  
#qualified_level ⇒ Object
      52 53 54 55 56 57 58 59 60 61 62 63 64 65  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 52 def qualified_level case parts.compact.size when 4 :fully when 3 :database when 2 :schema when 1 :table else :none end end  | 
  
#quoted ⇒ Object
      71 72 73  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 71 def quoted parts.map { |p| quote(p) if p }.join SEPARATOR end  | 
  
#quoted_raw ⇒ Object
      75 76 77  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 75 def quoted_raw quote @raw_name end  | 
  
#schema_quoted ⇒ Object
      32 33 34  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 32 def schema_quoted schema ? quote(schema) : schema end  | 
  
#server_quoted ⇒ Object
      40 41 42  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 40 def server_quoted server ? quote(server) : server end  | 
  
#to_s ⇒ Object
      67 68 69  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 67 def to_s quoted end  |