Sha256: 77bb3d796d766dda4db64787c60efb454ac2a8bf51d207171f63e376976917c2

Contents?: true

Size: 534 Bytes

Versions: 2

Compression:

Stored size: 534 Bytes

Contents

require 'chillout/creations_container'

module Chillout
  module ActiveRecordCreationListener
    def inherited(subclass)
      super
      listen(subclass)
    end

    private
    def listen(monitored_class)
      class_name = monitored_class.name
      return unless class_name
      monitored_class.after_commit :on => :create do
        Rails.logger.debug "[Chillout] Model created: #{class_name}"
        Chillout.creations ||= CreationsContainer.new
        Chillout.creations.increment!(class_name)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chillout-0.8.9 lib/chillout/creation_listener.rb
chillout-0.8.5.1 lib/chillout/creation_listener.rb