Class: Airtable::Field
Overview
Object corresponding to an Airtable Field
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Resource
Instance Method Summary collapse
-
#field_url ⇒ Object
protected
Endpoint for tables.
-
#initialize(token, table, id, data = nil) ⇒ Field
constructor
A new instance of Field.
- #update(field_data) ⇒ Airtable::Field
Methods inherited from Resource
Constructor Details
#initialize(token, table, id, data = nil) ⇒ Field
Returns a new instance of Field.
7 8 9 10 11 12 13 14 15 |
# File 'lib/airtable/field.rb', line 7 def initialize(token, table, id, data = nil) super(token) @table = table @base = @table.base @id = id data&.each_key do |key| instance_variable_set(:"@#{key}", data[key]) end end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
5 6 7 |
# File 'lib/airtable/field.rb', line 5 def base @base end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/airtable/field.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/airtable/field.rb', line 5 def @options end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
5 6 7 |
# File 'lib/airtable/field.rb', line 5 def table @table end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/airtable/field.rb', line 5 def type @type end |
Instance Method Details
#field_url ⇒ Object (protected)
Endpoint for tables
31 |
# File 'lib/airtable/field.rb', line 31 def field_url = "/v0/meta/bases/#{@base.id}/tables/#{@table.id}/fields/#{@id}" |
#update(field_data) ⇒ Airtable::Field
19 20 21 22 23 24 25 26 |
# File 'lib/airtable/field.rb', line 19 def update(field_data) response = self.class.patch(field_url, body: field_data.to_json).parsed_response check_and_raise_error(response) Airtable::Field.new(@token, @table, response) end |