Class: DataImp::Tds::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/data_imp/tds/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, table, schema:) ⇒ Table

Returns a new instance of Table.



3
4
5
6
7
# File 'lib/data_imp/tds/table.rb', line 3

def initialize client, table, schema:
  @client = client
  @table = table
  @schema = schema
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



2
3
4
# File 'lib/data_imp/tds/table.rb', line 2

def client
  @client
end

#schemaObject (readonly)

Returns the value of attribute schema.



2
3
4
# File 'lib/data_imp/tds/table.rb', line 2

def schema
  @schema
end

#tableObject (readonly)

Returns the value of attribute table.



2
3
4
# File 'lib/data_imp/tds/table.rb', line 2

def table
  @table
end

Instance Method Details

#each(&block) ⇒ Object



21
22
23
# File 'lib/data_imp/tds/table.rb', line 21

def each &block
  result.each &block
end

#resultObject



17
18
19
# File 'lib/data_imp/tds/table.rb', line 17

def result
  @result ||= client.execute(sql)
end

#sqlObject



9
10
11
12
13
14
15
# File 'lib/data_imp/tds/table.rb', line 9

def sql
  if schema
    "select * from [#{schema}].[#{table}]"
  else
    "select * from [#{table}]"
  end
end