Class: BigQuery::Tabledata::InsertRows
- Inherits:
-
Object
- Object
- BigQuery::Tabledata::InsertRows
- Defined in:
- lib/bigquery-client/insert_rows.rb
Defined Under Namespace
Classes: InsertError
Instance Method Summary collapse
- #call ⇒ Object
- #handle_errors(errors) ⇒ Object
-
#initialize(client, table, arg) ⇒ InsertRows
constructor
A new instance of InsertRows.
Constructor Details
#initialize(client, table, arg) ⇒ InsertRows
7 8 9 10 |
# File 'lib/bigquery-client/insert_rows.rb', line 7 def initialize(client, table, arg) @client, @table = client, table @rows = arg.is_a?(Array) ? arg : [arg] end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 |
# File 'lib/bigquery-client/insert_rows.rb', line 12 def call result = @client.insert_all(@table, @rows) handle_errors(result['insertErrors']) if result['insertErrors'] result end |
#handle_errors(errors) ⇒ Object
18 19 20 |
# File 'lib/bigquery-client/insert_rows.rb', line 18 def handle_errors(errors) fail InsertError, errors end |