Class: Airtable::Base
Overview
Object corresponding to an Airtable Base
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#base_url ⇒ Object
protected
Endpoint for bases.
- #create_table(table_data) ⇒ Airtable::Table
-
#initialize(token, id, tables = nil) ⇒ Base
constructor
A new instance of Base.
-
#table(table_id) ⇒ Airtable::Table
Instantiate table in base.
- #tables ⇒ Array<Airtable::Table>
Methods inherited from Resource
Constructor Details
#initialize(token, id, tables = nil) ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 |
# File 'lib/airtable/base.rb', line 5 def initialize(token, id, tables = nil) super(token) @id = id @tables = tables end |
Instance Method Details
#base_url ⇒ Object (protected)
Endpoint for bases
45 |
# File 'lib/airtable/base.rb', line 45 def base_url = "/v0/meta/bases/#{@id}" |
#create_table(table_data) ⇒ Airtable::Table
14 15 16 17 18 19 20 21 |
# File 'lib/airtable/base.rb', line 14 def create_table(table_data) response = self.class.post("#{base_url}/tables", body: table_data.to_json).parsed_response check_and_raise_error(response) Airtable::Table.new @token, self, response['id'], response end |
#table(table_id) ⇒ Airtable::Table
Instantiate table in base
38 39 40 |
# File 'lib/airtable/base.rb', line 38 def table(table_id) Airtable::Table.new(@token, @id, table_id) end |
#tables ⇒ Array<Airtable::Table>
25 26 27 28 29 30 31 32 33 |
# File 'lib/airtable/base.rb', line 25 def tables @tables ||= begin response = self.class.get("#{base_url}/tables") check_and_raise_error(response) response['tables'].map { Airtable::Table.new(@token, self, _1['id'], _1) } end end |