Class: RailsApp::ConfigFile
- Inherits:
-
Object
- Object
- RailsApp::ConfigFile
- Defined in:
- lib/rails_app/config_file.rb
Instance Method Summary collapse
- #exist? ⇒ Boolean
- #full_path ⇒ Object
-
#initialize ⇒ ConfigFile
constructor
A new instance of ConfigFile.
- #read ⇒ Object
- #set(key, value) ⇒ Object
- #write(force: false) ⇒ Object
Constructor Details
#initialize ⇒ ConfigFile
Returns a new instance of ConfigFile.
7 8 9 10 11 12 |
# File 'lib/rails_app/config_file.rb', line 7 def initialize @config = TTY::Config.new @config.append_path(Dir.home) @config.filename = "rails_app-config" @config.extname = ".yml" end |
Instance Method Details
#exist? ⇒ Boolean
14 15 16 |
# File 'lib/rails_app/config_file.rb', line 14 def exist? @config.exist? end |
#full_path ⇒ Object
26 27 28 |
# File 'lib/rails_app/config_file.rb', line 26 def full_path File.join(@config.location_paths[0] + "/" + @config.filename + @config.extname) end |
#read ⇒ Object
30 31 32 33 |
# File 'lib/rails_app/config_file.rb', line 30 def read @config.read if exist? @config.to_h end |
#set(key, value) ⇒ Object
18 19 20 |
# File 'lib/rails_app/config_file.rb', line 18 def set(key, value) @config.set(key, value: value) end |
#write(force: false) ⇒ Object
22 23 24 |
# File 'lib/rails_app/config_file.rb', line 22 def write(force: false) @config.write(force: force) end |