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 Inspired from Rails PostgreSQL::Name adapter object in their own Utils.
Constant Summary collapse
- 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.
19 20 21 22 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 19 def initialize(name) @raw_name = name.to_s parse_raw_name end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
16 17 18 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 16 def database @database end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
16 17 18 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 16 def object @object end |
#raw_name ⇒ Object (readonly)
Returns the value of attribute raw_name.
17 18 19 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 17 def raw_name @raw_name end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
16 17 18 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 16 def schema @schema end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
16 17 18 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 16 def server @server end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
75 76 77 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 75 def ==(other) other.class == self.class && other.parts == parts end |
#database_quoted ⇒ Object
32 33 34 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 32 def database_quoted database ? quote(database) : database end |
#fully_qualified? ⇒ Boolean
44 45 46 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 44 def fully_qualified? qualified_level == :fully end |
#fully_qualified_database_quoted ⇒ Object
40 41 42 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 40 def fully_qualified_database_quoted [server_quoted, database_quoted].compact.join('.') end |
#hash ⇒ Object
80 81 82 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 80 def hash parts.hash end |
#object_quoted ⇒ Object
24 25 26 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 24 def object_quoted quote object end |
#qualified_level ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 48 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
67 68 69 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 67 def quoted parts.map { |p| quote(p) if p }.join('.') end |
#quoted_raw ⇒ Object
71 72 73 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 71 def quoted_raw quote @raw_name end |
#schema_quoted ⇒ Object
28 29 30 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 28 def schema_quoted schema ? quote(schema) : schema end |
#server_quoted ⇒ Object
36 37 38 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 36 def server_quoted server ? quote(server) : server end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/active_record/connection_adapters/sqlserver/utils.rb', line 63 def to_s quoted end |