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: 'dbo') ⇒ 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: 'dbo'
  @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



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

def each &block
  result.each &block
end

#resultObject



13
14
15
# File 'lib/data_imp/tds/table.rb', line 13

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

#sqlObject



9
10
11
# File 'lib/data_imp/tds/table.rb', line 9

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