Class: TheTracker::Tracker

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/the_tracker/tracker.rb

Overview

Common tracker behaviour

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config {|self.instance| ... } ⇒ Object

Yields:

  • (self.instance)


8
9
10
# File 'lib/the_tracker/tracker.rb', line 8

def self.config
  yield self.instance if block_given?
end

Instance Method Details

#add(tracker) ⇒ Object

register a new tracker



13
14
15
# File 'lib/the_tracker/tracker.rb', line 13

def add(tracker)
  regular_trackers[tracker.name] = tracker
end

#add_once(tracker) ⇒ Object

register a new one time only tracker



18
19
20
# File 'lib/the_tracker/tracker.rb', line 18

def add_once(tracker)
  one_time_trackers[tracker.name] = tracker
end

#body_bottomObject

Return body bottom content for all registered trackers



38
39
40
41
42
# File 'lib/the_tracker/tracker.rb', line 38

def body_bottom
  trk_result = show_trackers_for(:body_bottom)
  remove_one_time_trackers
  return trk_result
end

#body_topObject

Return body top content for all registered trackers



33
34
35
# File 'lib/the_tracker/tracker.rb', line 33

def body_top
  show_trackers_for(:body_top)
end

#headerObject

Return header content for all registered trackers



28
29
30
# File 'lib/the_tracker/tracker.rb', line 28

def header
  show_trackers_for(:header)
end

#trackersObject

registered trackers



23
24
25
# File 'lib/the_tracker/tracker.rb', line 23

def trackers
  one_time_trackers.empty? ? regular_trackers : regular_trackers.merge(one_time_trackers)
end