Class: Airtable::ORM::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/airtable/orm/configuration.rb

Overview

Every host touchpoint is injected here — the gem never reads Rails.*, ENV, or credentials itself. Wired by the host application via Airtable::ORM.configure (in Rails typically from an initializer, inside to_prepare).

Defined Under Namespace

Classes: MemoryCache

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



15
16
17
18
19
20
21
22
23
24
# File 'lib/airtable/orm/configuration.rb', line 15

def initialize
  @tables = {}
  @api_url = "https://api.airtable.com"
  @open_timeout = 5
  @read_timeout = 10
  @rate_limit = 5                # Airtable throttles for 30 seconds above 5 requests/s per base
  @logger = Logger.new(IO::NULL)
  @http_logger = nil             # set to a Logger to enable Faraday request logging
  @cache = MemoryCache.new       # schema cache default; hosts inject Rails.cache
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def api_key
  @api_key
end

#api_urlObject

Returns the value of attribute api_url.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def api_url
  @api_url
end

#base_idObject

Returns the value of attribute base_id.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def base_id
  @base_id
end

#cacheObject

Returns the value of attribute cache.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def cache
  @cache
end

#http_loggerObject

Returns the value of attribute http_logger.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def http_logger
  @http_logger
end

#loggerObject

Returns the value of attribute logger.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def logger
  @logger
end

#open_timeoutObject

Returns the value of attribute open_timeout.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def open_timeout
  @open_timeout
end

#rate_limitObject

Returns the value of attribute rate_limit.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def rate_limit
  @rate_limit
end

#read_timeoutObject

Returns the value of attribute read_timeout.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def read_timeout
  @read_timeout
end

#tablesObject

Returns the value of attribute tables.



11
12
13
# File 'lib/airtable/orm/configuration.rb', line 11

def tables
  @tables
end

Instance Method Details

#table_fields(table_name) ⇒ Object

Example: table_fields(:case) => { _id: "id", advisors: "fldgU5KU1qlN8eJ3v", ... }



27
28
29
# File 'lib/airtable/orm/configuration.rb', line 27

def table_fields(table_name)
  tables.dig(table_name.to_sym, :fields)
end

#table_id(table_name) ⇒ Object

Example: table_id(:case) => "tblQeKH7yYesvWf5p"



32
33
34
# File 'lib/airtable/orm/configuration.rb', line 32

def table_id(table_name)
  tables.dig(table_name.to_sym, :id)
end

#table_idsObject



36
37
38
# File 'lib/airtable/orm/configuration.rb', line 36

def table_ids
  tables.values.pluck(:id)
end