Class: RbBigQuery::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/rbbigquery/schema.rb

Overview

Schema Builder

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#schemaObject

Returns the value of attribute schema.



4
5
6
# File 'lib/rbbigquery/schema.rb', line 4

def schema
  @schema
end

Class Method Details

.build(&blk) ⇒ Array<Hash>

Builds schema for BigQuery

Parameters:

  • &blk (Proc)

    RbBigQuery schema DSL

Returns:

  • (Array<Hash>)


10
11
12
13
14
15
# File 'lib/rbbigquery/schema.rb', line 10

def build(&blk)
  instance = new
  instance.schema = []
  instance.instance_eval &blk
  instance.schema
end

Instance Method Details

#integer(name) ⇒ Object



25
26
27
28
29
30
# File 'lib/rbbigquery/schema.rb', line 25

def integer(name)
  self.schema.push({
    type: 'INTEGER',
    name: name
  })
end

#string(name) ⇒ Object



18
19
20
21
22
23
# File 'lib/rbbigquery/schema.rb', line 18

def string(name)
  self.schema.push({
    type: 'STRING',
    name: name
  })
end