Sha256: 6fae94dfbf1d26d5e35ddff1dfc9033f8ee6eb7f44a77c72b4537ebd2dd0e619

Contents?: true

Size: 1008 Bytes

Versions: 1

Compression:

Stored size: 1008 Bytes

Contents

module Paperclip
  class WithDefault
    cattr_accessor :options
    
    # Default options for CloudFiles.
    def self.cloudfiles_options
      @cloudfiles_options ||= {
        :url           => ":container_url/attachments/:class/:attachment/:id/:style/:filename",
        :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
paperclip_cloudfiles-0.0.4 lib/paperclip/with_default.rb