Class: Tenon::ProxyAttachment
- Inherits:
-
Object
- Object
- Tenon::ProxyAttachment
- Defined in:
- lib/tenon/proxy_attachment.rb
Instance Attribute Summary collapse
-
#asset ⇒ Object
readonly
Returns the value of attribute asset.
-
#attachment ⇒ Object
readonly
Returns the value of attribute attachment.
-
#style_prefix ⇒ Object
readonly
Returns the value of attribute style_prefix.
Instance Method Summary collapse
- #display_name ⇒ Object
-
#initialize(attachment, klass, asset_name) ⇒ ProxyAttachment
constructor
A new instance of ProxyAttachment.
- #original_filename ⇒ Object
-
#url(style = :original, *args) ⇒ Object
Prefix with an underscore to use base Asset styles.
Constructor Details
#initialize(attachment, klass, asset_name) ⇒ ProxyAttachment
Returns a new instance of ProxyAttachment.
5 6 7 8 9 |
# File 'lib/tenon/proxy_attachment.rb', line 5 def initialize(, klass, asset_name) @attachment = .try(:attachment) || @asset = if .is_a?(Tenon::Asset) @style_prefix = "#{klass.to_s.underscore.gsub('/', '_')}_#{asset_name}" end |
Instance Attribute Details
#asset ⇒ Object (readonly)
Returns the value of attribute asset.
3 4 5 |
# File 'lib/tenon/proxy_attachment.rb', line 3 def asset @asset end |
#attachment ⇒ Object (readonly)
Returns the value of attribute attachment.
3 4 5 |
# File 'lib/tenon/proxy_attachment.rb', line 3 def @attachment end |
#style_prefix ⇒ Object (readonly)
Returns the value of attribute style_prefix.
3 4 5 |
# File 'lib/tenon/proxy_attachment.rb', line 3 def style_prefix @style_prefix end |
Instance Method Details
#display_name ⇒ Object
15 16 17 |
# File 'lib/tenon/proxy_attachment.rb', line 15 def display_name Tenon::AssetDecorator.new(@attachment.instance).display_name end |
#original_filename ⇒ Object
11 12 13 |
# File 'lib/tenon/proxy_attachment.rb', line 11 def original_filename @attachment.original_filename end |
#url(style = :original, *args) ⇒ Object
Prefix with an underscore to use base Asset styles
20 21 22 23 24 25 26 |
# File 'lib/tenon/proxy_attachment.rb', line 20 def url(style = :original, *args) if style.to_sym == :original original_url(*args) else named_url(style, *args) end end |