Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
22%
def upload_sizing; result = {:export => {use: []}} && (uploads_enabled? && (dims_upload = (upload_width? && upload_height? && { width: upload_width, height: upload_height }) || nil) || true) && (dims_thumb = (upload_thumb_width? && upload_thumb_height?) ? { width: upload_thumb_width, height: upload_thumb_height } : nil)) && [[enable_images?, dims_upload, :resize],[enable_images?, dims_thumb, :resize_thumb],[enable_videos?, dims_upload, :encode],[enable_videos?, dims_thumb, :encode_thumb]].inject(result) { |result, (cond, dims, key)| cond && dims && (result[key.to_sym] = dims) && (result[:export][:use] << key.to_s) }) || result; end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment