Class: Airtable::Record
Overview
Object corresponding to an Airtable Record
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Attributes inherited from Resource
Instance Method Summary collapse
-
#data ⇒ Hash
Return record data, retrieve if not present.
-
#initialize(token, table, id, data = nil) ⇒ Record
constructor
A new instance of Record.
-
#record_url ⇒ Object
protected
Endpoint for records.
- #update(record_data) ⇒ Airtable::Record
Methods inherited from Resource
Constructor Details
#initialize(token, table, id, data = nil) ⇒ Record
Returns a new instance of Record.
7 8 9 10 11 12 13 |
# File 'lib/airtable/record.rb', line 7 def initialize(token, table, id, data = nil) super(token) @table = table @base = @table.base @id = id @data = data end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
5 6 7 |
# File 'lib/airtable/record.rb', line 5 def base @base end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
5 6 7 |
# File 'lib/airtable/record.rb', line 5 def table @table end |
Instance Method Details
#data ⇒ Hash
Return record data, retrieve if not present
18 19 20 21 22 23 24 25 26 |
# File 'lib/airtable/record.rb', line 18 def data @data ||= begin response = self.class.get(record_url).parsed_response check_and_raise_error(response) response end end |
#record_url ⇒ Object (protected)
Endpoint for records
42 |
# File 'lib/airtable/record.rb', line 42 def record_url = "/v0/#{@base.id}/#{@table.id}/#{@id}" |
#update(record_data) ⇒ Airtable::Record
30 31 32 33 34 35 36 37 |
# File 'lib/airtable/record.rb', line 30 def update(record_data) response = self.class.patch(record_url, body: { fields: record_data }.to_json).parsed_response check_and_raise_error(response) Airtable::Record.new @token, @base.id, @table.id, response['id'], response end |