Sha256: 901b65d16c8921b0df14272b0d2b2c0e4ef70896478cbb968df616cc67d0fc04

Contents?: true

Size: 977 Bytes

Versions: 3

Compression:

Stored size: 977 Bytes

Contents

require 'paperclip'
require 'delayed_paperclip'

module DelayedPaperclip
  if defined? Rails::Railtie
    require 'rails'

    # On initialzation, include DelayedPaperclip
    class Railtie < Rails::Railtie
      initializer 'delayed_paperclip.insert_into_active_record' do |app|
        ActiveSupport.on_load :active_record do
          DelayedPaperclip::Railtie.insert
        end

        if app.config.respond_to?(:delayed_paperclip_defaults)
          DelayedPaperclip.options.merge!(app.config.delayed_paperclip_defaults)
        end
      end
    end
  end

  class Railtie

    # Glue includes DelayedPaperclip Class Methods and Instance Methods into ActiveRecord
    # Attachment and URL Generator extends Paperclip
    def self.insert
      ActiveRecord::Base.send(:include, DelayedPaperclip::Glue)
      Paperclip::Attachment.send(:include, DelayedPaperclip::Attachment)
      Paperclip::UrlGenerator.send(:include, DelayedPaperclip::UrlGenerator)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
delayed_paperclip-2.9.1 lib/delayed_paperclip/railtie.rb
delayed_paperclip-2.9.0 lib/delayed_paperclip/railtie.rb
delayed_paperclip-2.8.0 lib/delayed_paperclip/railtie.rb