Sha256: a4513f3256b0e394456d9134580ed61b18c310e114c1afb82f16dccb298e2bba

Contents?: true

Size: 791 Bytes

Versions: 1

Compression:

Stored size: 791 Bytes

Contents

module PaperclipPrivate
	module Attachment

		def self.included(base)
			base.extend ClassMethods 
			base.prepend Initializer
		end

		module ClassMethods

			def default_options
				super.merge({privacy: :public})
			end

		end

		module Initializer
			def initialize(name, instance, options = {})
	      defaults = self.class.default_options.dup
	      if options[:privacy] == :private # change default options if private before merging with options.
	        defaults[:path] = ":rails_root/:privacy#{defaults[:url]}"
	        defaults[:url] = "#{Rails.application.routes.url_helpers.paperclip_private_engine_path}/private/:klass/:id/:attachment_singular/:style" 
	      end
	      options = defaults.deep_merge(options)

	      super(name, instance, options)
	    end
		end

		

	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paperclip_private-0.0.2 lib/paperclip_private/attachment.rb