Module: Jekyll::Airtable::Configuration

Included in:
Jekyll::Airtable
Defined in:
lib/jekyll-airtable/configuration.rb

Constant Summary collapse

API_URL =
'https://api.airtable.com/'
API_VERSION =
'v0'
VALID_OPTIONS_KEYS =

An array of valid keys in the options hash

[
  :endpoint,
  :api_version,
  :api_key,
  :base_uid
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values



18
19
20
# File 'lib/jekyll-airtable/configuration.rb', line 18

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Convenience method to allow configuration options to be set in a block To be called from the base class

Yields:

  • (_self)

Yield Parameters:



31
32
33
# File 'lib/jekyll-airtable/configuration.rb', line 31

def configure
  yield self
end

#optionsObject

Create a hash of options and their values



23
24
25
26
27
# File 'lib/jekyll-airtable/configuration.rb', line 23

def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end

#resetObject

Reset all configuration options to defaults



36
37
38
39
40
41
# File 'lib/jekyll-airtable/configuration.rb', line 36

def reset
  self.endpoint           = API_URL
  self.api_version        = API_VERSION
  self.api_key            = nil
  self.base_uid           = ''
end