Class: ActiveRecord::ConnectionAdapters::PostgreSQL::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/postgresql/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

Instance Method Summary collapse

Constructor Details

#initialize(schema, identifier) ⇒ Name

Returns a new instance of Name.



12
13
14
# File 'lib/active_record/connection_adapters/postgresql/utils.rb', line 12

def initialize(schema, identifier)
  @schema, @identifier = unquote(schema), unquote(identifier)
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



10
11
12
# File 'lib/active_record/connection_adapters/postgresql/utils.rb', line 10

def identifier
  @identifier
end

#schemaObject (readonly)

Returns the value of attribute schema.



10
11
12
# File 'lib/active_record/connection_adapters/postgresql/utils.rb', line 10

def schema
  @schema
end

Instance Method Details

#==(o) ⇒ Object Also known as: eql?



28
29
30
# File 'lib/active_record/connection_adapters/postgresql/utils.rb', line 28

def ==(o)
  o.class == self.class && o.parts == parts
end

#hashObject



33
34
35
# File 'lib/active_record/connection_adapters/postgresql/utils.rb', line 33

def hash
  parts.hash
end

#quotedObject



20
21
22
23
24
25
26
# File 'lib/active_record/connection_adapters/postgresql/utils.rb', line 20

def quoted
  if schema
    PG::Connection.quote_ident(schema) << SEPARATOR << PG::Connection.quote_ident(identifier)
  else
    PG::Connection.quote_ident(identifier)
  end
end

#to_sObject



16
17
18
# File 'lib/active_record/connection_adapters/postgresql/utils.rb', line 16

def to_s
  parts.join SEPARATOR
end