Skip to content

Commit 364dbaa

Browse files
author
Yonah Forst
committed
accept proc as input/output value
1 parent 76679ab commit 364dbaa

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Paperclip
22
module Av
33
module Transcoder
4-
VERSION = "0.6.4"
4+
VERSION = "0.6.5"
55
end
66
end
77
end

lib/paperclip/paperclip_processors/transcoder.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def initialize file, options = {}, attachment = nil
1717

1818
@convert_options = set_convert_options(options)
1919

20+
@attachment = attachment
21+
2022
@format = options[:format]
2123

2224
@geometry = options[:geometry]
@@ -36,7 +38,19 @@ def initialize file, options = {}, attachment = nil
3638

3739
@convert_options[:output][:s] = format_geometry(@geometry) if @geometry.present?
3840

39-
attachment.instance_write(:meta, @meta) if attachment
41+
@attachment.instance_write(:meta, @meta) if @attachment
42+
end
43+
44+
def process_param param
45+
key = param[0]
46+
value = param[1]
47+
48+
return param if !value.is_a? Proc
49+
50+
new_value = value.call(@attachment.instance)
51+
puts "#{key} has new value: #{new_value}"
52+
53+
return [ key, new_value ] if new_value.present?
4054
end
4155

4256
# Performs the transcoding of the +file+ into a thumbnail/video. Returns the Tempfile
@@ -62,12 +76,14 @@ def make
6276
if @convert_options.present?
6377
if @convert_options[:input]
6478
@convert_options[:input].each do |h|
65-
@cli.add_input_param h
79+
param = process_param(h)
80+
@cli.add_input_param(param) if param.present?
6681
end
6782
end
6883
if @convert_options[:output]
6984
@convert_options[:output].each do |h|
70-
@cli.add_output_param h
85+
param = process_param(h)
86+
@cli.add_output_param(param) if param.present?
7187
end
7288
end
7389
end

0 commit comments

Comments
 (0)