View Source Trunk.VersionState (trunk v1.5.1)
This module defines a Trunk.VersionState
struct and provides some helper functions for working with that state.
Most of these fields are used internally during processing.
Fields
The following fields are available in the version state object. Some values are filled in during processing.
temp_path
- The path to the temporary file created for transformation. If the version doesn't undergo transformation, no temporary path will be available.transform
- The transform instruction returned fromTrunk.transform/2
storage_dir
- The storage directory returned fromTrunk.storage_dir/2
filename
- The filename returned fromTrunk.filename/2
storage_opts
- The additional storage options returned fromTrunk.storage_opts/2
assigns
- shared user data as a map (Same as assigns inPlug.Conn
)
Usage
This information is made available during Trunk.postprocess/3
which is called once the transformation is complete but before the storage callbacks are called. At this point you can work with the transformed version file and assign data that can be used later when determining the storage directory, filename and storage options.
Summary
Functions
Assigns a value to a key on the state.
Types
Functions
Assigns a value to a key on the state.
Example:
iex> version_state.assigns[:hello]
nil
iex> version_state = assign(version_state, :hello, :world)
iex> version_state.assigns[:hello]
:world