@@ -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