@@ -45,25 +45,38 @@ def self.configuration
4545 #
4646 # Returns the Transloadit authentication object.
4747 #
48- def self . transloadit
48+ # options - The Hash options used to refine the auth params (default: {}):
49+ # :max_size - The Integer maximum size an upload can have in bytes (optional).
50+ def self . transloadit ( options = { } )
4951 Transloadit . new (
5052 :key => self . configuration [ 'auth' ] [ 'key' ] ,
5153 :secret => self . configuration [ 'auth' ] [ 'secret' ] ,
5254 :duration => self . configuration [ 'auth' ] [ 'duration' ] ,
53- :max_size => self . configuration [ 'auth' ] [ 'max_size' ]
55+ :max_size => options [ :max_size ] || self . configuration [ 'auth' ] [ 'max_size' ]
5456 )
5557 end
5658
5759 #
5860 # Creates an assembly for the named template.
5961 #
62+ # name - The String or Symbol template name.
63+ # options - The Hash options used to refine the Assembly (default: {}):
64+ # :steps - The Hash with Assembly Steps (optional).
65+ # :max_size - The Integer maximum size an upload can have in bytes (optional).
6066 def self . template ( name , options = { } )
67+ transloadit = self . transloadit (
68+ :max_size => options . delete ( :max_size )
69+ )
70+
6171 template = self . configuration [ 'templates' ] . try ( :fetch , name . to_s )
72+ assembly_options = case template
73+ when String
74+ { :template_id => template } . merge ( options )
75+ when Hash
76+ template . merge ( options )
77+ end
6278
63- self . transloadit . assembly case template
64- when String then { :template_id => template } . merge ( options )
65- when Hash then template . merge ( options )
66- end
79+ transloadit . assembly ( assembly_options )
6780 end
6881
6982 #
0 commit comments