Sha256: 2e377e89707b9297df0b1ed729441f186888b9f1ea146911d4d8c0f73d1661ec

Contents?: true

Size: 688 Bytes

Versions: 31

Compression:

Stored size: 688 Bytes

Contents

module Ddr
  module Models
    module EventLoggable
      extend ActiveSupport::Concern

      def events
        event_class.for_object(self)
      end

      def update_events
        event_class(:update).for_object(self)
      end

      # TESTME
      def notify_event(type, args={})
        Ddr::Notifications.notify_event(type, args.merge(pid: id))
      end

      def has_events?
        events.count > 0
      end

      private

      def event_class_name(token=nil)
        type = token ? "#{token.to_s.camelize}Event" : "Event"
        "Ddr::Events::#{type}"
      end

      def event_class(token=nil)
        event_class_name(token).constantize
      end

    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
ddr-models-3.0.8 lib/ddr/models/event_loggable.rb
ddr-models-3.0.7 lib/ddr/models/event_loggable.rb
ddr-models-3.0.6 lib/ddr/models/event_loggable.rb
ddr-models-3.0.5 lib/ddr/models/event_loggable.rb
ddr-models-3.0.4 lib/ddr/models/event_loggable.rb
ddr-models-3.0.3 lib/ddr/models/event_loggable.rb
ddr-models-3.0.2 lib/ddr/models/event_loggable.rb
ddr-models-3.0.1 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.rc6 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.rc5 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.rc4 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.rc3 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.rc2 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.rc1 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.beta.22 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.beta.21 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.beta.20 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.beta.18 lib/ddr/models/event_loggable.rb
ddr-models-3.0.0.beta.17 lib/ddr/models/event_loggable.rb