Class: RefMaterial

Inherits:
SatelliteAsset show all
Defined in:
app/models/media/ref_material.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SatelliteAsset

#fileupload_destroy, #retrieve, #type_name, #upload, #uri, #url, #x_accel_url

Methods inherited from Asset

find_klass, #uri, #x_accel_url

Class Method Details

.destroy(params) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/models/media/ref_material.rb', line 11

def destroy(params)
  {
    files: [
      remoteupload_klass.destroy(params).try(:attributes)
    ]
  }
rescue JsonApiClient::Errors::ApiError
  { files: [] }
end

.remoteupload_klassObject



21
22
23
# File 'app/models/media/ref_material.rb', line 21

def remoteupload_klass
  TranslationCms::Api::Customers::ReferenceMaterial
end

Instance Method Details

#as_json(options = nil) ⇒ Object



30
31
32
33
34
35
36
37
# File 'app/models/media/ref_material.rb', line 30

def as_json(options = nil)
  options = {
    root: false,
    only: [:id, :guid, :assetable_id, :assetable_type, :user_id, :public_token],
    methods: [:filename, :url, :thumb_url, :size, :content_type, :remote_token]
  }.merge(options || {})
  super(options)
end

#remote_tokenObject



26
27
28
# File 'app/models/media/ref_material.rb', line 26

def remote_token
  data.try(:file).try(:public_token)
end

#remoteupload_klassObject



43
44
45
# File 'app/models/media/ref_material.rb', line 43

def remoteupload_klass
  self.class.remoteupload_klass
end

#thumb_urlObject



8
# File 'app/models/media/ref_material.rb', line 8

def thumb_url; end

#to_fileuploadObject



39
40
41
# File 'app/models/media/ref_material.rb', line 39

def to_fileupload
  as_json
end