Class: Freighthop::Config
- Inherits:
-
Object
- Object
- Freighthop::Config
- Defined in:
- lib/freighthop/config.rb
Class Method Summary collapse
- .config ⇒ Object
- .exist? ⇒ Boolean
- .fetch(*args) ⇒ Object
- .file ⇒ Object
- .write(config_hash) ⇒ Object
Class Method Details
.config ⇒ Object
10 11 12 |
# File 'lib/freighthop/config.rb', line 10 def self.config @config ||= JSON.parse(file.read) end |
.exist? ⇒ Boolean
2 3 4 |
# File 'lib/freighthop/config.rb', line 2 def self.exist? file.exist? end |
.fetch(*args) ⇒ Object
14 15 16 |
# File 'lib/freighthop/config.rb', line 14 def self.fetch(*args) config.fetch(*args) end |
.file ⇒ Object
6 7 8 |
# File 'lib/freighthop/config.rb', line 6 def self.file Freighthop.host_root.join('.freighthop.json') end |
.write(config_hash) ⇒ Object
18 19 20 |
# File 'lib/freighthop/config.rb', line 18 def self.write(config_hash) file.open('w') { |f| f.puts(JSON.pretty_generate(config_hash)) } end |