Class: Tenon::ProxyAttachment

Inherits:
Object
  • Object
show all
Defined in:
lib/tenon/proxy_attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attachment, klass, asset_name) ⇒ ProxyAttachment

Returns a new instance of ProxyAttachment.



5
6
7
8
# File 'lib/tenon/proxy_attachment.rb', line 5

def initialize(attachment, klass, asset_name)
  @attachment = attachment.try(:attachment) || attachment
  @style_prefix = "#{klass.to_s.underscore.gsub('/', '_')}_#{asset_name}"
end

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



3
4
5
# File 'lib/tenon/proxy_attachment.rb', line 3

def attachment
  @attachment
end

Instance Method Details

#display_nameObject



14
15
16
# File 'lib/tenon/proxy_attachment.rb', line 14

def display_name
  Tenon::AssetDecorator.new(@attachment.instance).display_name
end

#original_filenameObject



10
11
12
# File 'lib/tenon/proxy_attachment.rb', line 10

def original_filename
  @attachment.original_filename
end

#url(style = :original, *args) ⇒ Object

Prefix with an underscore to use base Asset styles



19
20
21
22
23
24
25
# File 'lib/tenon/proxy_attachment.rb', line 19

def url(style = :original, *args)
  if style.to_sym == :original
    original_url(*args)
  else
    named_url(style, *args)
  end
end