Class: BridgetownDirectus::Configuration
- Inherits:
-
Object
- Object
- BridgetownDirectus::Configuration
- Defined in:
- lib/bridgetown_directus.rb,
lib/bridgetown_directus/configuration.rb
Overview
Configuration module for Bridgetown Directus plugin
Defined Under Namespace
Classes: CollectionConfig
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#collections ⇒ Object
readonly
Returns the value of attribute collections.
-
#ssl_verify ⇒ Object
Returns the value of attribute ssl_verify.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
-
.instance ⇒ Object
Returns the singleton Configuration instance.
-
.reset! ⇒ Object
Reset the singleton (useful in tests).
Instance Method Summary collapse
-
#find_collection(name) ⇒ CollectionConfig?
Find a collection by name.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#register_collection(name, &block) ⇒ CollectionConfig
Register a new collection with the given name.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
45 46 47 48 |
# File 'lib/bridgetown_directus.rb', line 45 def initialize @collections = {} @ssl_verify = true end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
42 43 44 |
# File 'lib/bridgetown_directus.rb', line 42 def api_url @api_url end |
#collections ⇒ Object (readonly)
Returns the value of attribute collections.
43 44 45 |
# File 'lib/bridgetown_directus.rb', line 43 def collections @collections end |
#ssl_verify ⇒ Object
Returns the value of attribute ssl_verify.
42 43 44 |
# File 'lib/bridgetown_directus.rb', line 42 def ssl_verify @ssl_verify end |
#token ⇒ Object
Returns the value of attribute token.
42 43 44 |
# File 'lib/bridgetown_directus.rb', line 42 def token @token end |
Class Method Details
.instance ⇒ Object
Returns the singleton Configuration instance
51 52 53 |
# File 'lib/bridgetown_directus.rb', line 51 def self.instance @instance ||= new end |
.reset! ⇒ Object
Reset the singleton (useful in tests)
56 57 58 |
# File 'lib/bridgetown_directus.rb', line 56 def self.reset! @instance = nil end |
Instance Method Details
#find_collection(name) ⇒ CollectionConfig?
Find a collection by name
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
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 |