Sha256: 9bb2121aaf68ee1e25cd069885025bcce977827e6dec333f7b8a39283c22dd69

Contents?: true

Size: 503 Bytes

Versions: 5

Compression:

Stored size: 503 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
      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

5 entries across 5 versions & 1 rubygems

Version Path
chillout-0.8.8 lib/chillout/creation_listener.rb
chillout-0.8.7 lib/chillout/creation_listener.rb
chillout-0.8.6 lib/chillout/creation_listener.rb
chillout-0.8.5 lib/chillout/creation_listener.rb
chillout-0.8.4 lib/chillout/creation_listener.rb