Sha256: 01a9f2a7b9032a2ac22a1c9971305645729fb4754886c7008e74412fa574b67f

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

module Paperclip
  class WithDefault
    cattr_accessor :options
    
    # Default options for CloudFiles.
    def self.cloudfiles_options
      @cloudfiles_options ||= {
        :url           => ":cf_base_url/:path",
        :path          => "attachments/:class/:attachment/:id/:style/:filename",
        :storage       => :cloudfiles
      }
    end
    
    # Sets Paperclip::WithDefault.options to the given option
    # hash merged with Paperclip::WithDefault.cloudfiles_options
    def self.use_cloudfiles_options(options)
      Paperclip::WithDefault.options = cloudfiles_options.merge(options)
    end
    
    
    module ClassMethods
      
      # Simply calls has_attached_file with the default values found in
      # Paperclip::WitDefault.options merged into options.
      def has_attached_file_with_defaults(name, options = {})
        has_attached_file name, Paperclip::WithDefault.options.merge(options)
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
erikhansson-paperclip_cloudfiles-0.0.2 lib/paperclip/with_default.rb