Class: BridgetownDirectus::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/bridgetown_directus/configuration.rb,
lib/bridgetown_directus.rb

Overview

Configuration module for Bridgetown Directus plugin

Defined Under Namespace

Classes: CollectionConfig

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



28
29
30
# File 'lib/bridgetown_directus.rb', line 28

def initialize
  @collections = {}
end

Instance Attribute Details

#api_urlObject

Returns the value of attribute api_url.



25
26
27
# File 'lib/bridgetown_directus.rb', line 25

def api_url
  @api_url
end

#collectionsObject (readonly)

Returns the value of attribute collections.



26
27
28
# File 'lib/bridgetown_directus.rb', line 26

def collections
  @collections
end

#tokenObject

Returns the value of attribute token.



25
26
27
# File 'lib/bridgetown_directus.rb', line 25

def token
  @token
end

Instance Method Details

#find_collection(name) ⇒ CollectionConfig?

Find a collection by name

Parameters:

  • name (Symbol)

    The name of the collection

Returns:



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

def find_collection(name)
  @collections[name]
end

#register_collection(name, &block) ⇒ CollectionConfig

Register a new collection with the given name

Parameters:

  • name (Symbol)

    The name of the collection

  • block (Proc)

    Configuration block for the collection

Returns:



17
18
19
20
21
22
# File 'lib/bridgetown_directus/configuration.rb', line 17

def register_collection(name, &block)
  collection = CollectionConfig.new(name)
  collection.instance_eval(&block) if block_given?
  @collections[name] = collection
  collection
end