Class: SkylabStudio::Config
- Inherits:
-
Object
- Object
- SkylabStudio::Config
- Defined in:
- lib/skylab_studio/config.rb
Constant Summary collapse
- DEFAULT_URL =
'https://studio.skylabtech.ai'.freeze
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #method_missing(meth, *args, &block) ⇒ Object
- #respond_to_missing?(meth, include_private = false) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
24 25 26 |
# File 'lib/skylab_studio/config.rb', line 24 def initialize( = {}) @settings = SkylabStudio::Config.defaults.merge() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/skylab_studio/config.rb', line 28 def method_missing(meth, *args, &block) meth_str = meth.to_s if meth_str.include?('=') # If this is a write attempt, see if we can write to that key meth_sym = meth_str.delete('=').to_sym has?(meth_sym) ? @settings[meth_sym] = args[0] : super else # It's a read attempt, see if that key exists has?(meth) ? @settings[meth] : super end end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
5 6 7 |
# File 'lib/skylab_studio/config.rb', line 5 def settings @settings end |
Class Method Details
.defaults ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/skylab_studio/config.rb', line 9 def self.defaults source = URI.parse(DEFAULT_URL) { url: DEFAULT_URL, api_key: nil, protocol: source.scheme, host: source.host, port: source.port, api_version: 'v1', debug: true, client_stub: "ruby-#{VERSION}" } end |
Instance Method Details
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
42 43 44 |
# File 'lib/skylab_studio/config.rb', line 42 def respond_to_missing?(meth, include_private = false) has?(meth) || super end |