Class: BigShift::CreateTableCommand

Inherits:
BaseCommand show all
Defined in:
lib/big_shift/commands/create_table_command.rb

Instance Method Summary collapse

Methods inherited from BaseCommand

execute, #execute

Constructor Details

#initialize(schema) ⇒ CreateTableCommand

Returns a new instance of CreateTableCommand.



3
4
5
# File 'lib/big_shift/commands/create_table_command.rb', line 3

def initialize(schema)
  @schema = schema
end

Instance Method Details

#bodyObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/big_shift/commands/create_table_command.rb', line 15

def body
  {
    'tableReference' => {
      'projectId' => project_id,
      'datasetId' => dataset_id,
      'tableId'   => @schema.table_name,
    },

    'schema' => @schema,
  }
end

#endpointObject



11
12
13
# File 'lib/big_shift/commands/create_table_command.rb', line 11

def endpoint
  'tables'
end

#on_executeObject



7
8
9
# File 'lib/big_shift/commands/create_table_command.rb', line 7

def on_execute
  CreateTableResponse.new post
end