Sha256: 57d28c8a6ea4e0fbc7b27e24459ca01e2247da845d7b2a958b31cf24055d7e4b

Contents?: true

Size: 1.03 KB

Versions: 120

Compression:

Stored size: 1.03 KB

Contents

module Paperclip
  # This module is intended as a compatability shim for the differences in
  # callbacks between Rails 2.0 and Rails 2.1.
  module CallbackCompatability
    def self.included(base)
      base.extend(ClassMethods)
      base.send(:include, InstanceMethods)
    end

    module ClassMethods
      # The implementation of this method is taken from the Rails 1.2.6 source,
      # from rails/activerecord/lib/active_record/callbacks.rb, line 192.
      def define_callbacks(*args)
        args.each do |method|
          self.class_eval <<-"end_eval"
            def self.#{method}(*callbacks, &block)
              callbacks << block if block_given?
              write_inheritable_array(#{method.to_sym.inspect}, callbacks)
            end
          end_eval
        end
      end
    end

    module InstanceMethods
      # The callbacks in < 2.1 don't worry about the extra options or the
      # block, so just run what we have available.
      def run_callbacks(meth, opts = nil, &blk)
        callback(meth)
      end
    end
  end
end

Version data entries

120 entries across 120 versions & 37 rubygems

Version Path
area17-paperclip-2.2.9.1.1 lib/paperclip/callback_compatability.rb
area17-paperclip-2.2.9.2.1 lib/paperclip/callback_compatability.rb
area17-paperclip-2.2.9.2.2 lib/paperclip/callback_compatability.rb
area17-paperclip-2.2.9.2.3 lib/paperclip/callback_compatability.rb
area17-paperclip-2.2.9.2.4 lib/paperclip/callback_compatability.rb
area17-paperclip-2.3.1 lib/paperclip/callback_compatability.rb
beaucollins-paperclip-2.2.7 lib/paperclip/callback_compatability.rb
betelgeuse-paperclip-2.2.8.1 lib/paperclip/callback_compatability.rb
dancroak-paperclip-2.3.1 lib/paperclip/callback_compatability.rb
dejanstrbac-paperclip-2.2.9.2 lib/paperclip/callback_compatability.rb
doxo-paperclip-2.3.1 lib/paperclip/callback_compatability.rb
fermion-paperclip-2.2.8 lib/paperclip/callback_compatability.rb
heythisisnate-paperclip-2.3.0.1 lib/paperclip/callback_compatability.rb
heythisisnate-paperclip-2.3.0.2 lib/paperclip/callback_compatability.rb
heythisisnate-paperclip-2.3.0.5 lib/paperclip/callback_compatability.rb
joshpuetz-paperclip-2.3.0.1 lib/paperclip/callback_compatability.rb
joshpuetz-paperclip-2.3.0.2 lib/paperclip/callback_compatability.rb
joshpuetz-paperclip-2.3.0 lib/paperclip/callback_compatability.rb
korobkov-paperclip-2.3.1.20090921 lib/paperclip/callback_compatability.rb
korobkov-paperclip-2.3.1.200909221442 lib/paperclip/callback_compatability.rb