Sha256: 3d43949046b4fe78da4cf78c632d392be20c13e1597a658dcf7280f857ffb1db
Contents?: true
Size: 887 Bytes
Versions: 1
Compression:
Stored size: 887 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 privacy = options[:privacy] privacy = privacy.call(instance) if privacy.respond_to?(:call) if 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.3 | lib/paperclip_private/attachment.rb |