Class: Torque::PostgreSQL::TableName
- Inherits:
-
Delegator
- Object
- Delegator
- Torque::PostgreSQL::TableName
- Defined in:
- lib/torque/postgresql/table_name.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #__setobj__(value) ⇒ Object
-
#initialize(klass, table_name) ⇒ TableName
constructor
A new instance of TableName.
- #schema ⇒ Object
- #to_s ⇒ Object (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) ⇒ Object
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) ⇒ Object
30 31 32 |
# File 'lib/torque/postgresql/table_name.rb', line 30 def __setobj__(value) @table_name = value end |
#schema ⇒ Object
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 ⇒ Object 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 |