Sha256: f1b97da7682de87539fae7d4cd8e9ea9a2e3d914c72124fbc31f8f17c58d01d5

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

module CassandraObject
  module Callbacks
    extend ActiveSupport::Concern
    include ActiveSupport::Callbacks
    
    included do
      define_model_callbacks :save, :create, :destroy, :update
    end
    
    module ClassMethods
      def define_model_callbacks(*callbacks)
        callbacks.each do |callback|
          define_callbacks "before_#{callback}"
          define_callbacks "after_#{callback}"
        end
      end
    end
    
    module InstanceMethods
      def run_callbacks(callback)
        if block_given?
          unless false == super("before_#{callback}")
            yield.tap do
              super("after_#{callback}")
            end
          end
        else
          super
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cassandra_object-0.6.0.pre lib/cassandra_object/legacy_callbacks.rb