module Nozzle::Adapter::Outlet
Public Class Methods
included(base)
click to toggle source
# File lib/nozzle/adapter/outlet.rb, line 5 def self.included(base) base.instance_eval do def outlets @outlets ||= {} end end base.extend(ClassMethods) end
Public Instance Methods
cleanup!()
click to toggle source
# File lib/nozzle/adapter/outlet.rb, line 44 def cleanup! delete_file_and_folder!( path ) if respond_to?(:version_name) outlets.each{ |name, outlet| outlet.cleanup! } end
outlets()
click to toggle source
# File lib/nozzle/adapter/outlet.rb, line 7 def outlets @outlets ||= {} end
prepare( original, result )
click to toggle source
Copies the file from original path to this outlet path.
prepare( original, result )
This method SHOULD be overridden in the outlet block. Example:
class NewAdapter < Nozzle::Adapter::Base outlet :thumb do def prepare( original, result ) `convert #{original} -thumbnail x96 #{result}` end end end
In the example system convert
is called to resize the original file and save it’s smaller version in result path.
# File lib/nozzle/adapter/outlet.rb, line 35 def prepare( original, result ) FileUtils.mkdir_p File.dirname(result) FileUtils.cp original, result end
prepare!()
click to toggle source
# File lib/nozzle/adapter/outlet.rb, line 40 def prepare! prepare( @record.send(@column).path, path ) end