Module: SearchKit::Configuration
- Included in:
- SearchKit
- Defined in:
- lib/search_kit/configuration.rb
Instance Method Summary collapse
- #config ⇒ Object
- #configure {|config| ... } ⇒ Object
- #fetch(key) ⇒ Object
- #set_config(key, value) ⇒ Object
- #show_config(key) ⇒ Object
Instance Method Details
#config ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/search_kit/configuration.rb', line 13 def config return @config if @config root = UserConfig.new(".search-kit") yaml = root['config.yml'] config = OpenStruct.new yaml.each { |key, value| config.send("#{key}=", value) } @config = config end |
#configure {|config| ... } ⇒ Object
9 10 11 |
# File 'lib/search_kit/configuration.rb', line 9 def configure yield(config) if block_given? end |
#fetch(key) ⇒ Object
36 37 38 |
# File 'lib/search_kit/configuration.rb', line 36 def fetch(key) ENV.fetch(key, show_config(key.downcase) || default(key.to_sym)) end |
#set_config(key, value) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/search_kit/configuration.rb', line 23 def set_config(key, value) root = UserConfig.new(".search-kit") yaml = root['config.yml'] yaml[key] = value yaml.save end |
#show_config(key) ⇒ Object
31 32 33 34 |
# File 'lib/search_kit/configuration.rb', line 31 def show_config(key) root = UserConfig.new(".search-kit") root['config.yml'][key] end |