Class: BigShift::CreateViewCommand

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

Instance Method Summary collapse

Methods inherited from BaseCommand

execute, #execute

Constructor Details

#initialize(name, query) ⇒ CreateViewCommand

Returns a new instance of CreateViewCommand.



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

def initialize(name, query)
  @name = name
  @query = query
end

Instance Method Details

#bodyObject



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

def body
  {
    'tableReference' => {
      'projectId' => project_id,
      'datasetId' => dataset_id,
      'tableId'   => @name,
    },
    'view': {
      'query': @query
    }
  }
end

#endpointObject



12
13
14
# File 'lib/big_shift/commands/create_view_command.rb', line 12

def endpoint
  'tables'
end

#on_executeObject



8
9
10
# File 'lib/big_shift/commands/create_view_command.rb', line 8

def on_execute
  CreateTableResponse.new post
end