Class: Elasticonf::Config
- Inherits:
-
Object
- Object
- Elasticonf::Config
- Defined in:
- lib/elasticonf/config.rb
Instance Method Summary collapse
- #config_file ⇒ Object
- #config_file=(value) ⇒ Object
- #config_root ⇒ Object
- #config_root=(value) ⇒ Object
- #const_name ⇒ Object
- #const_name=(value) ⇒ Object
- #env ⇒ Object
- #env=(value) ⇒ Object
- #raise_if_already_initialized_constant ⇒ Object
- #raise_if_already_initialized_constant=(value) ⇒ Object
- #reset_config! ⇒ Object
Instance Method Details
#config_file ⇒ Object
37 38 39 |
# File 'lib/elasticonf/config.rb', line 37 def config_file @config_file ||= 'settings' end |
#config_file=(value) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/elasticonf/config.rb', line 41 def config_file=(value) unless [String, Symbol].include?(value.class) raise ArgumentError, "String or Symbol expected #{value.class} given" end @config_file = value.to_s end |
#config_root ⇒ Object
26 27 28 |
# File 'lib/elasticonf/config.rb', line 26 def config_root @config_root ||= raise(ArgumentError, 'You must specify config_root option first') end |
#config_root=(value) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/elasticonf/config.rb', line 30 def config_root=(value) unless [String, Symbol, Pathname].include?(value.class) raise ArgumentError, "String or Symbol or Pathname expected #{value.class} given" end @config_root = value.is_a?(Pathname) ? value : Pathname.new(value.to_s) end |
#const_name ⇒ Object
48 49 50 |
# File 'lib/elasticonf/config.rb', line 48 def const_name @const_name ||= 'Settings' end |
#const_name=(value) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/elasticonf/config.rb', line 52 def const_name=(value) unless [String, Symbol].include?(value.class) raise ArgumentError, "String or Symbol expected #{value.class} given" end @const_name = value.to_s end |
#env ⇒ Object
15 16 17 |
# File 'lib/elasticonf/config.rb', line 15 def env @env ||= 'development' end |
#env=(value) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/elasticonf/config.rb', line 19 def env=(value) unless [String, Symbol].include?(value.class) raise ArgumentError, "String or Symbol expected #{value.class} given" end @env = value.to_s end |
#raise_if_already_initialized_constant ⇒ Object
59 60 61 |
# File 'lib/elasticonf/config.rb', line 59 def raise_if_already_initialized_constant @raise_if_already_initialized_constant.nil? ? true : @raise_if_already_initialized_constant end |
#raise_if_already_initialized_constant=(value) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/elasticonf/config.rb', line 63 def raise_if_already_initialized_constant=(value) unless [TrueClass, FalseClass].include?(value.class) raise ArgumentError, "TrueClass or FalseClass expected #{value.class} given" end @raise_if_already_initialized_constant = value end |
#reset_config! ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/elasticonf/config.rb', line 3 def reset_config! %w( env config_root config_file const_name raise_if_already_initialized_constant ).each do |v| instance_variable_set "@#{v}", nil end end |