Class: RailsRequests::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_requests/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ Record

key = metrics|HomeController|index|20200123T0919|1579789173|/|database = 0 value = string



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_requests/record.rb', line 8

def initialize(key, value)
  @key   = key
  @value = value

  items = key.split("|")

  @controller = items[1]
  @action     = items[2]
  @datetime   = items[3]
  @datetimei  = items[4].to_i
  @path       = items[5]
  @metric     = items[6]
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



4
5
6
# File 'lib/rails_requests/record.rb', line 4

def action
  @action
end

#controllerObject (readonly)

Returns the value of attribute controller.



4
5
6
# File 'lib/rails_requests/record.rb', line 4

def controller
  @controller
end

#datetimeObject (readonly)

Returns the value of attribute datetime.



4
5
6
# File 'lib/rails_requests/record.rb', line 4

def datetime
  @datetime
end

#datetimeiObject (readonly)

Returns the value of attribute datetimei.



4
5
6
# File 'lib/rails_requests/record.rb', line 4

def datetimei
  @datetimei
end

#metricObject (readonly)

Returns the value of attribute metric.



4
5
6
# File 'lib/rails_requests/record.rb', line 4

def metric
  @metric
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/rails_requests/record.rb', line 4

def path
  @path
end

Instance Method Details

#controller_actionObject



31
32
33
# File 'lib/rails_requests/record.rb', line 31

def controller_action
  "#{controller}##{action}"
end

#valueObject



22
23
24
25
26
27
28
29
# File 'lib/rails_requests/record.rb', line 22

def value
  case metric
  when "database", "view_duration", "total_duration"
    @value.to_f
  when "all"
    JSON.parse(@value)
  end
end