Class: Types::Objects::Base::AttachmentType

Inherits:
BaseObject
  • Object
show all
Defined in:
app/graphql/types/objects/base/attachment_type.rb

Instance Method Summary collapse

Instance Method Details

#filenameObject



15
16
17
18
19
20
21
# File 'app/graphql/types/objects/base/attachment_type.rb', line 15

def filename
  if object.class.eql?(ActiveStorage::Variant)
    object.blob.filename.to_s + "-" + object.variation.transformations[:resize]
  else
    object.filename.to_s
  end
end

#idObject



7
8
9
10
11
12
13
# File 'app/graphql/types/objects/base/attachment_type.rb', line 7

def id
  if object.class.eql?(ActiveStorage::Variant)
    object.blob.id
  else
    object.id
  end
end

#urlObject



23
24
25
26
27
28
29
30
31
# File 'app/graphql/types/objects/base/attachment_type.rb', line 23

def url
  if object.class.eql?(ActiveStorage::Variant)
    Rails.application.routes.url_helpers.rails_representation_url(object)
  elsif defined?(object.service_url)
    object.service_url
  else
    object.url
  end
end