class Paperclip::GoogleDrive::Config
@api private
Constants
- FIELDS
Public Class Methods
new(config_path)
click to toggle source
# File lib/paperclip/google_drive/config.rb, line 14 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 if !client_id auth_client = Google::Auth::ClientId.from_file(config_path) @client_id = auth_client.id @client_secret = auth_client.secret end end end
Public Instance Methods
save()
click to toggle source
# File lib/paperclip/google_drive/config.rb, line 28 def save ::File.open(@config_path, 'w', 0600) { |f| f.write(to_json) } end
Private Instance Methods
to_json()
click to toggle source
# File lib/paperclip/google_drive/config.rb, line 34 def to_json hash = {} FIELDS.each do |field| value = __send__(field) hash[field] = value if value end JSON.pretty_generate(hash) end