Sha256: 894c7796774b31f59f68205051ba7cd390ee9695e8b977be1c7f7273ed24fe9c

Contents?: true

Size: 470 Bytes

Versions: 2

Compression:

Stored size: 470 Bytes

Contents

require 'minuteman/event'

module Minuteman
  class Analyzer
    def initialize(action, klass = Minuteman::Event, user = nil)
      Minuteman.patterns.keys.each do |method|
        define_singleton_method(method) do |time = Time.now.utc|
          key = Minuteman.patterns[method].call(time)
          search = { type: action, time: key }
          search[:user_id] = user.id if !user.nil?

          klass.find_or_create(search)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
minuteman-3.0.0 lib/minuteman/analyzer.rb
minuteman-2.0.0 lib/minuteman/analyzer.rb