Sha256: 750ba2694840eff3c17f86e09e4b5a9d852fdbb66f92e7437a5b2b2c8334d240

Contents?: true

Size: 618 Bytes

Versions: 4

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

require 'wisper'

module Ditty
  class Listener
    def initialize
      @mutex = Mutex.new
    end

    def method_missing(method, *args)
      vals = { action: method }
      return unless args[0].is_a? Hash
      vals[:user] = args[0][:user] if args[0] && args[0].key?(:user)
      vals[:details] = args[0][:details] if args[0] && args[0].key?(:details)
      @mutex.synchronize { Ditty::AuditLog.create vals }
    end

    def respond_to_missing?(_method, _include_private = false)
      true
    end
  end
end

Wisper.subscribe(Ditty::Listener.new) unless ENV['RACK_ENV'] == 'test'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ditty-0.4.1 lib/ditty/listener.rb
ditty-0.4.0 lib/ditty/listener.rb
ditty-0.3.3 lib/ditty/listener.rb
ditty-0.3.2 lib/ditty/listener.rb