class CarrierWave::Blitline::ImageVersionFunctionPresenter

A presenter class for converting an image version to a JSON param for the Blitline

API.

Attributes

uploader[RW]

The Uploader instance we're processing an image for.

version[RW]

The ImageVersion we're presenting

Public Class Methods

new(version, uploader) click to toggle source

Creates a new presenter.

version - The ImageVersion to use uploader - The CarrierWave uploader instance

# File lib/carrierwave/blitline/image_version_function_presenter.rb, line 38
def initialize(version, uploader)
  @version  = version
  @uploader = uploader
end

Public Instance Methods

to_hash() click to toggle source

The Hash to be converted to JSON for the Blitline API

# File lib/carrierwave/blitline/image_version_function_presenter.rb, line 44
def to_hash
  {
    "name":   primary_function_name,
    "params": params_for_function(primary_function_name, primary_function_params),
    "save": {
      "image_identifier": unique_identifier,
      "s3_destination": {
        "bucket": {
          "name": CarrierWave::Blitline.s3_bucket_name,
          "location": CarrierWave::Blitline.s3_bucket_region
        },
        "key": file_name_for_version(version)
      }
    },
    "functions": functions_hashes
  }
end

Private Instance Methods

functions_hashes() click to toggle source
# File lib/carrierwave/blitline/image_version_function_presenter.rb, line 66
def functions_hashes
  secondary_functions.map do |function|
    {
      "name": function.name,
      "params": params_for_function(function.name, function.params),
      "save": {
        "image_identifier": unique_identifier,
        "s3_destination": {
          "bucket": {
            "name": CarrierWave::Blitline.s3_bucket_name,
            "location": CarrierWave::Blitline.s3_bucket_region
          },
          "key": file_name_for_version(version)
        }
      }
    }
  end
end