Sha256: 128b4b23b8d0817a969d1dd9904a9496c4ce2c960e1f84d35941d77073a04dec

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

module Hatio
  module RemTracker
    
    def self.included(base)
      super
      base.extend(ClassMethods)
      base.class_eval do
        include InstanceMethods
      end
    end

    module ClassMethods
      def removing_trackable
        class_eval do
          after_destroy :trace_removing
        end
      end
    end

    module InstanceMethods
      private
        def trace_removing
          # self 정보를 모두 REM_TRACES 테이블에 추가 
          rem_trace = RemTrace.new
          rem_trace.name = self.name if(self.respond_to?(:name))
          rem_trace.entity_type = self.class.name
          rem_trace.entity_id = self.id
          rem_trace.content = self.to_json
          rem_trace.domain_id = self.domain_id
          rem_trace.save!
        end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hatio-core-0.0.6 lib/hatio-core/active_record/rem_tracker.rb