Sha256: 31068e2f6723784f9e6e4a3a9d67034e8940fdeea8052cdabe87994ed0e829e1

Contents?: true

Size: 547 Bytes

Versions: 5

Compression:

Stored size: 547 Bytes

Contents

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 { AuditLog.create vals }
    end

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

Wisper.subscribe(Ditty::Listener.new)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ditty-0.3.1 lib/ditty/listener.rb
ditty-0.3.0 lib/ditty/listener.rb
ditty-0.2.2 lib/ditty/listener.rb
ditty-0.2.1 lib/ditty/listener.rb
ditty-0.2.0 lib/ditty/listener.rb