module Boffin::Trackable
Can be included into a class that responds to ‘#as_member`, `#to_i`, or `#to_s`. It’s recommended to use {Boffin.track} to inject Trackable
into a class. It provides the instance methods of Tracker
scoped to the host class and its instances.
@example
class MyModel < ActiveRecord::Base include Boffin::Trackable boffin.hit_types = [:views, :likes] end # Then record hits to instances of your model @my_model = MyModel.find(1) @my_model.hit(:views)
See {file:README} for more examples.
Public Class Methods
included(mod)
click to toggle source
@private
# File lib/boffin/trackable.rb, line 21 def self.included(mod) mod.extend(ClassMethods) end
Public Instance Methods
hit(type, opts = {})
click to toggle source
@see Tracker#hit
@return [Hit]
# File lib/boffin/trackable.rb, line 43 def hit(type, opts = {}) self.class.boffin.hit(type, self, opts) end
hit_count(type, opts = {})
click to toggle source
@see Tracker#hit_count @return [Float]
# File lib/boffin/trackable.rb, line 49 def hit_count(type, opts = {}) self.class.boffin.count(type, self, opts) end