Module: MongoidTraffic::Log::ClassMethods

Defined in:
lib/mongoid_traffic/log.rb

Instance Method Summary collapse

Instance Method Details

#additional_counter(name, as: nil) ⇒ Object



36
37
38
# File 'lib/mongoid_traffic/log.rb', line 36

def additional_counter(name, as: nil)
  field name, as: as, type: Hash, default: {}
end

#aggregate_on(att) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/mongoid_traffic/log.rb', line 40

def aggregate_on(att)
  field = find_field(att)
  case field.type.to_s
  when 'Integer' then sum(field.name)
  when 'Hash' then sum_hash(field.name)
  end
end

#log(*args) ⇒ Object



32
33
34
# File 'lib/mongoid_traffic/log.rb', line 32

def log(*args)
  MongoidTraffic::Logger.log(self, *args)
end