Class: MetOnTheMiddle::Readers::ViewTime

Inherits:
Base
  • Object
show all
Defined in:
lib/met_on_the_middle/readers/view_time.rb

Instance Attribute Summary

Attributes inherited from Base

#key

Instance Method Summary collapse

Methods inherited from Base

#register_subscription, #to_key_value

Constructor Details

#initializeViewTime

Returns a new instance of ViewTime.



4
5
6
# File 'lib/met_on_the_middle/readers/view_time.rb', line 4

def initialize
  super :view_time
end

Instance Method Details

#match_subscriptionObject



8
9
10
# File 'lib/met_on_the_middle/readers/view_time.rb', line 8

def match_subscription
  /render_(partial|template).action_view/
end

#parse(e, request: nil) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/met_on_the_middle/readers/view_time.rb', line 12

def parse(e, request: nil)
  path = e.payload[:identifier].split('/views/', 2)

  duration = 0
  duration = e.duration if path[1]

  (duration+(request.get(key)||0)).round(2)
end