123456789_123456789_123456789_123456789_123456789_

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

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: activerecord/lib/active_record/connection_adapters/postgresql/utils.rb

Overview

Value Object to hold a schema qualified name. This is usually the name of a ::ActiveRecord::ConnectionAdapters::PostgreSQL relation but it can also represent schema qualified type names. #schema and #identifier are unquoted to prevent double quoting.

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(schema, identifier) ⇒ Name

[ GitHub ]

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

def initialize(schema, identifier)
  @schema, @identifier = Utils.unquote_identifier(schema), Utils.unquote_identifier(identifier)
end

Instance Attribute Details

#identifier (readonly)

[ GitHub ]

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

attr_reader :schema, :identifier

#schema (readonly)

[ GitHub ]

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

attr_reader :schema, :identifier

Instance Method Details

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

[ GitHub ]

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

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

#eql?(o)

Alias for #==.

[ GitHub ]

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

alias_method :eql?, :==

#hash

[ GitHub ]

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

def hash
  parts.hash
end

#parts (protected)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/utils.rb', line 40

def parts
  @parts ||= [@schema, @identifier].compact
end

#quoted

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/utils.rb', line 22

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

[ GitHub ]

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

def to_s
  parts.join SEPARATOR
end