Class: Airtable::ORM::Configuration
- Inherits:
-
Object
- Object
- Airtable::ORM::Configuration
- 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
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#base_id ⇒ Object
Returns the value of attribute base_id.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#http_logger ⇒ Object
Returns the value of attribute http_logger.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#rate_limit ⇒ Object
Returns the value of attribute rate_limit.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#tables ⇒ Object
Returns the value of attribute tables.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#table_fields(table_name) ⇒ Object
Example: table_fields(:case) => { _id: "id", advisors: "fldgU5KU1qlN8eJ3v", ... }.
-
#table_id(table_name) ⇒ Object
Example: table_id(:case) => "tblQeKH7yYesvWf5p".
- #table_ids ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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_key ⇒ Object
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_url ⇒ Object
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_id ⇒ Object
Returns the value of attribute base_id.
11 12 13 |
# File 'lib/airtable/orm/configuration.rb', line 11 def base_id @base_id end |
#cache ⇒ Object
Returns the value of attribute cache.
11 12 13 |
# File 'lib/airtable/orm/configuration.rb', line 11 def cache @cache end |
#http_logger ⇒ Object
Returns the value of attribute http_logger.
11 12 13 |
# File 'lib/airtable/orm/configuration.rb', line 11 def http_logger @http_logger end |
#logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/airtable/orm/configuration.rb', line 11 def logger @logger end |
#open_timeout ⇒ Object
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_limit ⇒ Object
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_timeout ⇒ Object
Returns the value of attribute read_timeout.
11 12 13 |
# File 'lib/airtable/orm/configuration.rb', line 11 def read_timeout @read_timeout end |
#tables ⇒ Object
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_ids ⇒ Object
36 37 38 |
# File 'lib/airtable/orm/configuration.rb', line 36 def table_ids tables.values.pluck(:id) end |