lib/loaders/spree/image_loader.rb in datashift_spree-0.2.1 vs lib/loaders/spree/image_loader.rb in datashift_spree-0.3.0

- old
+ new

@@ -2,38 +2,27 @@ # Author :: Tom Statter # Date :: Jan 2011 # License:: MIT. Free, Open Source. # require 'loader_base' -#require 'paperclip/attachment_loader' module DataShift module SpreeHelper - - # Version Helper - find the right class to attach Product images to - def self.product_attachment_klazz - @product_attachment_klazz ||= if(DataShift::SpreeHelper::version.to_f > 1.0 ) - DataShift::SpreeHelper::get_spree_class('Variant' ) - else - DataShift::SpreeHelper::get_spree_class('Product' ) - end - end - # Very specific Image Loading for existing Products in Spree. # # Requirements : A CSV or Excel file which has 2+ columns # # 1) Identifies a Product via Name or SKU column # 2+) The full path(s) to the Images to attach to Product from column 1 # class ImageLoader < SpreeBaseLoader - def initialize(options = {}) + def initialize(image = nil, options = {}) - super( DataShift::SpreeHelper::get_spree_class('Image'), nil, options ) + super( DataShift::SpreeHelper::get_spree_class('Image'), true, image, options ) unless(MethodDictionary.for?(@@product_klass)) MethodDictionary.find_operators( @@product_klass ) MethodDictionary.build_method_details( @@product_klass ) end @@ -74,10 +63,10 @@ @@path_headers ||= ['attachment', 'images', 'path'] operator = @current_method_detail.operator - if(current_value && acceptable_path_headers.include?(operator) ) + if(current_value && ImageLoader::acceptable_path_headers.include?(operator) ) add_images( @load_object ) if(@load_object) elsif(current_value && @current_method_detail.operator ) \ No newline at end of file