Skip to content

Instantly share code, notes, and snippets.

@johnmaxwell
Created May 6, 2011 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnmaxwell/959692 to your computer and use it in GitHub Desktop.
Save johnmaxwell/959692 to your computer and use it in GitHub Desktop.
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