airtable 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3165b382ecbd4a24ad42665af0efc0c5afd6939
4
- data.tar.gz: 290704daa788ba1e747faee2b4fa2c0eba28650e
3
+ metadata.gz: c30642b3fa8febcd66284a8e5e9ae2ba31d2fd80
4
+ data.tar.gz: 091e5f21dab3280c075de8b20d119394a2166f6b
5
5
  SHA512:
6
- metadata.gz: a8930f5b657d96f1884ca4880c81f52f9939a85efe6371b9fdc902e55126fce585c6e9148cc1a522bc6faa2b60ec06d086d07ff2eb5a9ead3ed58388a649d5f0
7
- data.tar.gz: c79e04beb0a8f82aa1c011d206864ea182f2343efc47343bde6d13750c086393f6fe0b241296e320e01ade43a4f191bb1705428318ac4453a2aacdee1ebd3f7c
6
+ metadata.gz: 036e9dd3fa705cf45786b84f35c8da9c62ab10b011ecb473d54e14482ecc74e7e55cd2e65514c3ea9fbc18018782f7495ab0ad4ffcd8ba265b061eb86a650975
7
+ data.tar.gz: e307936150a2b994022df2da96a20d69e4f50434bd2902c972de41e903e68945771d5a5ae97ba5625448eb99fc0f5e2683dbf901e55a707447b90f0f21055336
@@ -34,7 +34,10 @@ module Airtable
34
34
  end
35
35
 
36
36
  # Hash with keys based on airtable original column names
37
- def fields; Hash[@columns_map.map { |k| [ k, @attrs[to_key(k)] ] }]; end
37
+ def fields; HashWithIndifferentAccess.new(Hash[@columns_map.map { |k| [ k, @attrs[to_key(k)] ] }]); end
38
+
39
+ # Airtable will complain if we pass an 'id' as part of the request body.
40
+ def fields_for_update; fields.except(:id); end
38
41
 
39
42
  def method_missing(name, *args, &blk)
40
43
  # Accessor for attributes
@@ -49,7 +49,7 @@ module Airtable
49
49
  # Replaces record in airtable based on id
50
50
  def update(record)
51
51
  result = self.class.put(worksheet_url + "/" + record.id,
52
- :body => { "fields" => record.fields }.to_json,
52
+ :body => { "fields" => record.fields_for_update }.to_json,
53
53
  :headers => { "Content-type" => "application/json" }).parsed_response
54
54
  if result.present? && result["id"].present?
55
55
  record.override_attributes!(result_attributes(result))
@@ -1,3 +1,3 @@
1
1
  module Airtable
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -41,6 +41,7 @@ describe Airtable do
41
41
  table.update(record)
42
42
  assert_equal "12345", record["id"]
43
43
  assert_equal "bar", record["foo"]
44
- end
44
+ end
45
+
45
46
  end # describe Airtable
46
47
  end # Airtable
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ describe Airtable do
4
+ describe Airtable::Record do
5
+ it "should not return id in fields_for_update" do
6
+ record = Airtable::Record.new(:name => "Sarah Jaine", :email => "sarah@jaine.com", :id => 12345)
7
+ record.fields_for_update.wont_include(:id)
8
+ end
9
+ end # describe Record
10
+ end # Airtable
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airtable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-01 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -116,6 +116,7 @@ files:
116
116
  - lib/airtable/table.rb
117
117
  - lib/airtable/version.rb
118
118
  - test/airtable_test.rb
119
+ - test/record_test.rb
119
120
  - test/test_helper.rb
120
121
  homepage: https://github.com/nesquena/airtable-ruby
121
122
  licenses:
@@ -143,4 +144,5 @@ specification_version: 4
143
144
  summary: Easily connect to airtable data using ruby
144
145
  test_files:
145
146
  - test/airtable_test.rb
147
+ - test/record_test.rb
146
148
  - test/test_helper.rb