Skip to content

Commit

Permalink
Merge pull request #50 from sirupsen/sans-warnings
Browse files Browse the repository at this point in the history
Drop warning re: @api_key not initialized
  • Loading branch information
chrisfrank committed Nov 27, 2018
2 parents 8fa3a89 + 96e7056 commit d74f942
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/airrecord/table.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
module Airrecord
class Table
class << self
attr_accessor :base_key, :table_name, :api_key, :associations
attr_accessor :base_key, :table_name
attr_writer :api_key

def client
@@clients ||= {}
@@clients[api_key] ||= Client.new(api_key)
end

def api_key
defined?(@api_key) ? @api_key : Airrecord.api_key
end

def has_many(method_name, options)
define_method(method_name.to_sym) do
# Get association ids in reverse order, because Airtable’s UI and API
Expand All @@ -28,10 +33,6 @@ def belongs_to(method_name, options)

alias has_one belongs_to

def api_key
@api_key || Airrecord.api_key
end

def find(id)
response = client.connection.get("/v0/#{base_key}/#{client.escape(table_name)}/#{id}")
parsed_response = client.parse(response.body)
Expand Down

0 comments on commit d74f942

Please sign in to comment.