Sha256: 32427a0ae027471c68577fb8bd639e96584ff3453e306f6aeb51268b04b26f0e

Contents?: true

Size: 605 Bytes

Versions: 12

Compression:

Stored size: 605 Bytes

Contents

module SuperModel
  module Callbacks
    extend ActiveSupport::Concern

    included do
      instance_eval do
        extend ActiveModel::Callbacks
        define_model_callbacks :create, :save, :update, :destroy
      end
      
      %w( create save update destroy ).each do |method|
        class_eval(<<-EOS, __FILE__, __LINE__ + 1)
          def #{method}_with_callbacks(*args, &block)
            _run_#{method}_callbacks do
              #{method}_without_callbacks(*args, &block)
            end
          end
        EOS
        alias_method_chain(method, :callbacks)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
supermodel-0.1.6 lib/supermodel/callbacks.rb
supermodel-0.1.5 lib/supermodel/callbacks.rb
csun-student-affairs-supermodel-0.1.5 lib/supermodel/callbacks.rb
supermodel-0.1.4 lib/supermodel/callbacks.rb
supermodel-0.1.3 lib/supermodel/callbacks.rb
supermodel-0.1.2 lib/supermodel/callbacks.rb
supermodel-0.1.0 lib/supermodel/callbacks.rb
supermodel-0.0.8 lib/supermodel/callbacks.rb
supermodel-0.0.6 lib/supermodel/callbacks.rb
supermodel-0.0.5 lib/supermodel/callbacks.rb
supermodel-0.0.4 lib/supermodel/callbacks.rb
supermodel-0.0.2 lib/supermodel/callbacks.rb