Class: TableSync::NamingResolver::Sequel

Inherits:
Object
  • Object
show all
Defined in:
lib/table_sync/naming_resolver/sequel.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_name:, db:) ⇒ Sequel

Returns a new instance of Sequel.



5
6
7
8
# File 'lib/table_sync/naming_resolver/sequel.rb', line 5

def initialize(table_name:, db:)
  @table_name = table_name
  @db = db
end

Instance Method Details

#schemaObject



14
15
16
17
# File 'lib/table_sync/naming_resolver/sequel.rb', line 14

def schema
  return table_name.table if table_name.is_a?(::Sequel::SQL::QualifiedIdentifier)
  db.get(Sequel.function("current_schema")) rescue "public"
end

#tableObject



10
11
12
# File 'lib/table_sync/naming_resolver/sequel.rb', line 10

def table
  table_name.is_a?(::Sequel::SQL::QualifiedIdentifier) ? table_name.column : table_name
end