Module: PushType::AssetsHelper
- Defined in:
- app/helpers/push_type/assets_helper.rb
Instance Method Summary collapse
- #asset_back_link(asset) ⇒ Object
- #asset_hash(asset) ⇒ Object
- #asset_icon(asset) ⇒ Object
- #asset_preview_thumb_url(asset) ⇒ Object
- #assets_array(assets) ⇒ Object
Instance Method Details
#asset_back_link(asset) ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/helpers/push_type/assets_helper.rb', line 29 def asset_back_link(asset) if asset.trashed? push_type.trash_assets_path else push_type.assets_path end end |
#asset_hash(asset) ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/helpers/push_type/assets_helper.rb', line 8 def asset_hash(asset) return nil if asset.nil? hash = [ :id, :file_name, :file_size, :mime_type, :created_at, :new_record?, :image?, :description_or_file_name ].inject({}) do |h, att| h.update att => asset.send(att) end hash.update preview_thumb_url: asset_preview_thumb_url(asset) end |
#asset_icon(asset) ⇒ Object
25 26 27 |
# File 'app/helpers/push_type/assets_helper.rb', line 25 def asset_icon(asset) "push_type/icons-assets.svg##{ asset.kind }" end |
#asset_preview_thumb_url(asset) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/helpers/push_type/assets_helper.rb', line 16 def asset_preview_thumb_url(asset) return nil unless asset.persisted? if asset.image? main_app.media_path(file_uid: asset.file_uid, style: :push_type_thumb) else image_path(asset_icon(asset)) end end |
#assets_array(assets) ⇒ Object
4 5 6 |
# File 'app/helpers/push_type/assets_helper.rb', line 4 def assets_array(assets) assets.map { |a| asset_hash(a) } end |