Module: Mongoid::Utils::Hitable

Extended by:
ActiveSupport::Concern
Defined in:
lib/mongoid/utils/hitable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#hitted(hit_digest) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/mongoid/utils/hitable.rb', line 13

def hitted(hit_digest)
  seen = hits.where(digest: hit_digest).count > 0

  unless seen
    hits.create(digest: hit_digest)
    self.hits_count = self.hits_count + 1
    self.timeless.save!(validate: false)
#          self.timeless.update_attribute(:hits_count, hits_count + 1)
  end
end