Class: Testcloud::Config::Settings
- Inherits:
-
Object
- Object
- Testcloud::Config::Settings
- Defined in:
- lib/testcloud/config/settings.rb
Constant Summary collapse
- PUBLIC_API_METHODS =
[:environment, :config_directory, :config_classname, :eager_load].freeze
Instance Method Summary collapse
- #config_classname ⇒ Object
- #config_classname=(konst) ⇒ Object
- #config_classname? ⇒ Boolean
- #config_directory ⇒ Object
- #config_directory=(dir) ⇒ Object
-
#eager_load ⇒ Object
(also: #eager_load?)
default eager_load to false.
-
#eager_load=(value) ⇒ Object
allow eager loading i.e.
- #environment ⇒ Object
- #environment=(env) ⇒ Object
-
#initialize(options = {}) ⇒ Settings
constructor
A new instance of Settings.
Constructor Details
#initialize(options = {}) ⇒ Settings
Returns a new instance of Settings.
9 10 11 12 13 14 15 16 |
# File 'lib/testcloud/config/settings.rb', line 9 def initialize( = {}) @eager_load = true # always eager_load unless overridden .slice!(*PUBLIC_API_METHODS) .each do |method_name, value| api_method = "#{method_name}=" self.public_send(api_method, value) if self.respond_to?(api_method) end end |
Instance Method Details
#config_classname ⇒ Object
50 51 52 |
# File 'lib/testcloud/config/settings.rb', line 50 def config_classname @config_classname end |
#config_classname=(konst) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/testcloud/config/settings.rb', line 43 def config_classname=(konst) unless konst.is_a?(String) raise Testcloud::Config::Errors::ConfigClassnameError.new("config_classname: #{konst.inspect} must be a String") end @config_classname = konst end |
#config_classname? ⇒ Boolean
54 55 56 |
# File 'lib/testcloud/config/settings.rb', line 54 def config_classname? !!config_classname end |
#config_directory ⇒ Object
36 37 38 39 40 41 |
# File 'lib/testcloud/config/settings.rb', line 36 def config_directory unless @config_directory raise Testcloud::Config::Errors::ConfigDirectoryError.new('config_directory must be defined.') end @config_directory end |
#config_directory=(dir) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/testcloud/config/settings.rb', line 29 def config_directory=(dir) unless File.exists?(dir) && File.directory?(dir) raise Testcloud::Config::Errors::ConfigDirectoryError.new("config_directory: #{dir.inspect} must exist and be a directory.") end @config_directory = dir end |
#eager_load ⇒ Object Also known as: eager_load?
default eager_load to false
64 65 66 |
# File 'lib/testcloud/config/settings.rb', line 64 def eager_load !!@eager_load end |
#eager_load=(value) ⇒ Object
allow eager loading i.e. load configuration files directly after setup block
59 60 61 |
# File 'lib/testcloud/config/settings.rb', line 59 def eager_load=(value) @eager_load = value end |
#environment ⇒ Object
22 23 24 25 26 27 |
# File 'lib/testcloud/config/settings.rb', line 22 def environment unless @environment raise Testcloud::Config::Errors::NoEnvironmentError.new('environment must be defined.') end @environment end |
#environment=(env) ⇒ Object
18 19 20 |
# File 'lib/testcloud/config/settings.rb', line 18 def environment=(env) @environment = env.respond_to?(:call) ? env.call : env end |