Class: GoogleDrive::Config
- Inherits:
-
Object
- Object
- GoogleDrive::Config
- Defined in:
- lib/google_drive/config.rb
Overview
:nodoc:
Constant Summary collapse
- FIELDS =
%w(client_id client_secret scope refresh_token).freeze
Instance Method Summary collapse
-
#initialize(config_path) ⇒ Config
constructor
A new instance of Config.
- #save ⇒ Object
Constructor Details
#initialize(config_path) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 18 |
# File 'lib/google_drive/config.rb', line 11 def initialize(config_path) @config_path = config_path if ::File.exist?(config_path) JSON.parse(::File.read(config_path)).each do |key, value| instance_variable_set("@#{key}", value) if FIELDS.include?(key) end end end |
Instance Method Details
#save ⇒ Object
20 21 22 |
# File 'lib/google_drive/config.rb', line 20 def save ::File.open(@config_path, 'w', 0600) { |f| f.write(to_json) } end |