Class: ActiveRecord::ConnectionAdapters::Redshift::Name
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::Redshift::Name
- Defined in:
- lib/active_record/connection_adapters/redshift_7_0/utils.rb,
lib/active_record/connection_adapters/redshift_7_1/utils.rb
Overview
Value Object to hold a schema qualified name. This is usually the name of a PostgreSQL relation but it can also represent schema qualified type names. schema
and identifier
are unquoted to prevent double quoting.
Constant Summary collapse
- SEPARATOR =
:nodoc:
'.'
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(schema, identifier) ⇒ Name
constructor
A new instance of Name.
- #quoted ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(schema, identifier) ⇒ Name
Returns a new instance of Name.
14 15 16 17 |
# File 'lib/active_record/connection_adapters/redshift_7_0/utils.rb', line 14 def initialize(schema, identifier) @schema = unquote(schema) @identifier = unquote(identifier) end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
12 13 14 |
# File 'lib/active_record/connection_adapters/redshift_7_0/utils.rb', line 12 def identifier @identifier end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
12 13 14 |
# File 'lib/active_record/connection_adapters/redshift_7_0/utils.rb', line 12 def schema @schema end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
31 32 33 |
# File 'lib/active_record/connection_adapters/redshift_7_0/utils.rb', line 31 def ==(other) other.class == self.class && other.parts == parts end |
#hash ⇒ Object
36 37 38 |
# File 'lib/active_record/connection_adapters/redshift_7_0/utils.rb', line 36 def hash parts.hash end |
#quoted ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/active_record/connection_adapters/redshift_7_0/utils.rb', line 23 def quoted if schema PG::Connection.quote_ident(schema) << SEPARATOR << PG::Connection.quote_ident(identifier) else PG::Connection.quote_ident(identifier) end end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/active_record/connection_adapters/redshift_7_0/utils.rb', line 19 def to_s parts.join SEPARATOR end |