Class: DotLocal::Configuration
- Inherits:
-
Object
- Object
- DotLocal::Configuration
- Defined in:
- lib/dot_local/configuration.rb
Constant Summary collapse
- SettingsFileName =
'settings.yml'
- LocalSuffix =
'local'
- ReservedKeys =
%w(env path file_name local_file_name raw)
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#local_file_name ⇒ Object
Returns the value of attribute local_file_name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #load! ⇒ Object
- #method_missing(*args) ⇒ Object
- #reload! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dot_local/configuration.rb', line 11 def initialize(={}) @path = .delete :path @file_name = .delete :file_name @local_file_name = .delete :local_file_name @env = .delete :env @path = File.('..', __FILE__) if @path.nil? @file_name ||= SettingsFileName @local_file_name ||= interpolate_local_filename end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
9 10 11 |
# File 'lib/dot_local/configuration.rb', line 9 def env @env end |
#file_name ⇒ Object
Returns the value of attribute file_name.
9 10 11 |
# File 'lib/dot_local/configuration.rb', line 9 def file_name @file_name end |
#local_file_name ⇒ Object
Returns the value of attribute local_file_name.
9 10 11 |
# File 'lib/dot_local/configuration.rb', line 9 def local_file_name @local_file_name end |
#path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/dot_local/configuration.rb', line 9 def path @path end |
#raw ⇒ Object
Returns the value of attribute raw.
9 10 11 |
# File 'lib/dot_local/configuration.rb', line 9 def raw @raw end |
Instance Method Details
#load! ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dot_local/configuration.rb', line 37 def load! raise DotLocal::DoubleLoad if @loaded @loaded = true @raw = parse(file_name) @parsed = @raw @raw = @raw.fetch(@env.to_s) unless @env.nil? merge_with_local! if local_exists? validate_blank_values! validate_reserved_keys! @raw.freeze end |
#reload! ⇒ Object
32 33 34 35 |
# File 'lib/dot_local/configuration.rb', line 32 def reload! @loaded = false self.load! end |