airrecord 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 96fc25d42d967d7a810f837ed83689650d4bcde7
4
- data.tar.gz: '058cb52c3f0a3a72ab093efb5052d90388dd9fb9'
2
+ SHA256:
3
+ metadata.gz: 0a4dcc6bb1ab38c832a2a47375709f336a339aeb6ce8a59f444aef7d0a593907
4
+ data.tar.gz: 4832ad61f71311634e3b55abeaa14ed235e714e86352f69ef2590ec8688d59c3
5
5
  SHA512:
6
- metadata.gz: 5a615028f21e1d195f9b7e72334e02833a245e27df39a97ddecdb7ead4fed4de0aa0155d2993e3f1e90059037b18c3fe8c60015f02f7e8176e509259e697cbb8
7
- data.tar.gz: f80dc3f0d28ddc8e2b4bf97b228f7d05cadfea62353aea9ab07912b7197c87a749bdfd696752d5ed2667b836e37bba04458fd17ac9fded709f213edadb02fb0a
6
+ metadata.gz: f9e3cad6f957ddc9beec914906e9ab9d975c30192042eeb7c445578d91a456008ebdec96ebbb2fcb8c0dfde750bf0c77d0642b5b059997c6d5105a1882a65fa0
7
+ data.tar.gz: 07cf5860116e8b50b05608bcb584517b0f9161ee08b1d7c54c9329a3bfb29f35d6e862e1944ada726f27c413652f5bf8b233fd0b44107eaf9e557885f39cac09
@@ -1,3 +1,7 @@
1
+ # 1.0.3
2
+
3
+ * Allow passing optional parameters, e.g. `typecast: true`. (#67)
4
+
1
5
  # 1.0.2
2
6
 
3
7
  * When a `has_one` or `belongs_to` association is empty, return `nil` instead of
data/README.md CHANGED
@@ -222,6 +222,22 @@ tea.save
222
222
  Note that column names need to match the exact column names in Airtable,
223
223
  otherwise Airrecord will throw an error that no column matches it.
224
224
 
225
+
226
+ If you need to include optional request parameters, such as the `typecast` parameter, these can be passed to either `Table.create` or `#save`.
227
+ This is also supported when updating existing records with the `#save` method.
228
+
229
+ ```ruby
230
+ tea = Tea.create(
231
+ {"Name" => "Feng Gang", "Type" => "Green", "Country" => "China"},
232
+ {"typecast" => true},
233
+ )
234
+
235
+ # Or with the #save method:
236
+ tea = Tea.new({"Name" => "Feng Gang", "Type" => "Green"})
237
+ tea["Name"] = "Feng Gang"
238
+ tea.save("typecast" => true)
239
+ ```
240
+
225
241
  _Earlier versions of airrecord provided methods for snake-cased column names
226
242
  and symbols, however this proved error-prone without a proper schema API from
227
243
  Airtable which has still not been released._
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'faraday', '~> 0.10'
24
24
  spec.add_dependency "net-http-persistent", '>= 2.9'
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.12"
26
+ spec.add_development_dependency "bundler", "~> 2.1.2"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_development_dependency "minitest", "~> 5.0"
29
29
  spec.add_development_dependency "byebug"
@@ -54,8 +54,8 @@ module Airrecord
54
54
  records(filter: formula).sort_by { |record| or_args.index(record.id) }
55
55
  end
56
56
 
57
- def create(fields)
58
- new(fields).tap { |record| record.save }
57
+ def create(fields, options={})
58
+ new(fields).tap { |record| record.save(options) }
59
59
  end
60
60
 
61
61
  def records(filter: nil, sort: nil, view: nil, offset: nil, paginate: true, fields: nil, max_records: nil, page_size: nil)
@@ -129,10 +129,14 @@ module Airrecord
129
129
  fields[key] = value
130
130
  end
131
131
 
132
- def create
132
+ def create(options={})
133
133
  raise Error, "Record already exists (record has an id)" unless new_record?
134
134
 
135
- body = { fields: serializable_fields }.to_json
135
+ body = {
136
+ fields: serializable_fields,
137
+ **options,
138
+ }.to_json
139
+
136
140
  response = client.connection.post("/v0/#{self.class.base_key}/#{client.escape(self.class.table_name)}", body, { 'Content-Type' => 'application/json' })
137
141
  parsed_response = client.parse(response.body)
138
142
 
@@ -145,8 +149,8 @@ module Airrecord
145
149
  end
146
150
  end
147
151
 
148
- def save
149
- return create if new_record?
152
+ def save(options={})
153
+ return create(options) if new_record?
150
154
 
151
155
  return true if @updated_keys.empty?
152
156
 
@@ -154,7 +158,8 @@ module Airrecord
154
158
  body = {
155
159
  fields: Hash[@updated_keys.map { |key|
156
160
  [key, fields[key]]
157
- }]
161
+ }],
162
+ **options,
158
163
  }.to_json
159
164
 
160
165
  response = client.connection.patch("/v0/#{self.class.base_key}/#{client.escape(self.class.table_name)}/#{self.id}", body, { 'Content-Type' => 'application/json' })
@@ -1,3 +1,3 @@
1
1
  module Airrecord
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airrecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Eskildsen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2019-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.12'
47
+ version: 2.1.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.12'
54
+ version: 2.1.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -136,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubyforge_project:
140
- rubygems_version: 2.5.2.3
139
+ rubygems_version: 3.0.3
141
140
  signing_key:
142
141
  specification_version: 4
143
142
  summary: Airtable client