Class: RailsApp::ConfigFile

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_app/config_file.rb

Instance Method Summary collapse

Constructor Details

#initializeConfigFile

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

Returns:

  • (Boolean)


14
15
16
# File 'lib/rails_app/config_file.rb', line 14

def exist?
  @config.exist?
end

#full_pathObject



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

#readObject



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