Class: Torque::PostgreSQL::TableName
- Inherits:
-
Delegator
- Object
- Delegator
- Torque::PostgreSQL::TableName
- Defined in:
- lib/torque/postgresql/table_name.rb,
sig/torque/postgresql/table_name.rbs
Instance Method Summary collapse
- #==(other) ⇒ Integer?
- #__setobj__(value) ⇒ String
-
#initialize(klass, table_name) ⇒ TableName
constructor
A new instance of TableName.
- #schema ⇒ String?
- #to_s ⇒ String (also: #__getobj__)
Constructor Details
#initialize(klass, table_name) ⇒ TableName
Returns a new instance of TableName.
6 7 8 9 |
# File 'lib/torque/postgresql/table_name.rb', line 6 def initialize(klass, table_name) @klass = klass @table_name = table_name end |
Instance Method Details
#==(other) ⇒ Integer?
26 27 28 |
# File 'lib/torque/postgresql/table_name.rb', line 26 def ==(other) other.to_s =~ /("?#{schema | search_path_schemes.join('|')}"?\.)?"?#{@table_name}"?/ end |
#__setobj__(value) ⇒ String
30 31 32 |
# File 'lib/torque/postgresql/table_name.rb', line 30 def __setobj__(value) @table_name = value end |
#schema ⇒ String?
11 12 13 14 15 16 17 18 |
# File 'lib/torque/postgresql/table_name.rb', line 11 def schema return @schema if defined?(@schema) @schema = ([@klass] + @klass.module_parents[0..-2]).find do |klass| next unless klass.respond_to?(:schema) && !(value = klass.schema).nil? break value end end |
#to_s ⇒ String Also known as: __getobj__
20 21 22 |
# File 'lib/torque/postgresql/table_name.rb', line 20 def to_s schema.nil? ? @table_name : "#{schema}.#{@table_name}" end |