Class: CarrierWave::Uploader::GoogleDrive

Inherits:
Base
  • Object
show all
Defined in:
lib/carrierwave/uploader/google_drive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keyObject

Returns the value of attribute key.



7
8
9
# File 'lib/carrierwave/uploader/google_drive.rb', line 7

def key
  @key
end

Instance Method Details

#build_version_hash(google_reource_id) ⇒ Object



17
18
19
# File 'lib/carrierwave/uploader/google_drive.rb', line 17

def build_version_hash(google_reource_id)
  load_version_hash.merge({ (version_name.blank? ? :default : version_name.to_sym) =>  google_reource_id })
end

#load_version_hashObject



21
22
23
24
25
26
# File 'lib/carrierwave/uploader/google_drive.rb', line 21

def load_version_hash
  _data = YAML.load(model.read_attribute("#{self.mounted_as}".to_sym))
  _data.is_a?(Hash) ? _data : { }
rescue
  { }
end

#updatemodel(file) ⇒ Object



13
14
15
# File 'lib/carrierwave/uploader/google_drive.rb', line 13

def updatemodel(file)
  model.update_column("#{self.mounted_as}".to_sym, build_version_hash(self.key).to_yaml)
end