Sha256: 57aee057721b47dd5a2e56a5e1f65ec6bbfd673f17cff799f76fba7439474ee2

Contents?: true

Size: 939 Bytes

Versions: 7

Compression:

Stored size: 939 Bytes

Contents

module PushType
  module AssetsHelper

    def assets_array(assets)
      assets.map { |a| asset_hash(a) }
    end

    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

    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

    def asset_icon(asset)
      "push_type/icons-assets.svg##{ asset.kind }"
    end

    def asset_back_link(asset)
      if asset.trashed?
        push_type.trash_assets_path
      else
        push_type.assets_path
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
push_type_admin-0.7.0 app/helpers/push_type/assets_helper.rb
push_type_admin-0.7.0.beta.1 app/helpers/push_type/assets_helper.rb
push_type_admin-0.6.0 app/helpers/push_type/assets_helper.rb
push_type_admin-0.6.0.beta.4 app/helpers/push_type/assets_helper.rb
push_type_admin-0.6.0.beta.3 app/helpers/push_type/assets_helper.rb
push_type_admin-0.6.0.beta.2 app/helpers/push_type/assets_helper.rb
push_type_admin-0.6.0.beta.1 app/helpers/push_type/assets_helper.rb