Sha256: 246bf9730183d1b6717612e72278608267bafa1bf092f720a81469d7984aa091

Contents?: true

Size: 814 Bytes

Versions: 3

Compression:

Stored size: 814 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
        ActiveSupport.on_load :active_record do
          DelayedPaperclip::Railtie.insert
        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.7.1 lib/delayed_paperclip/railtie.rb
delayed_paperclip-2.7.0 lib/delayed_paperclip/railtie.rb
delayed_paperclip-2.6.1 lib/delayed_paperclip/railtie.rb