Class: RailsLiveDashboard::Types::RequestContent

Inherits:
ActiveRecord::Type::Value
  • Object
show all
Defined in:
app/models/rails_live_dashboard/types/request_content.rb

Defined Under Namespace

Classes: CONTENT_STRUCT

Constant Summary collapse

PAYLOAD =
%i[
  controller
  action
  params
  format
  method
  path
  status
  headers
  body
  duration
  view_duration
  db_duration
  allocations
].freeze

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



27
28
29
30
# File 'app/models/rails_live_dashboard/types/request_content.rb', line 27

def cast(value)
  sanitized = sanitize_input(value)
  CONTENT_STRUCT.new(**sanitized)
end

#deserialize(value) ⇒ Object



32
33
34
35
36
# File 'app/models/rails_live_dashboard/types/request_content.rb', line 32

def deserialize(value)
  decoded = ActiveSupport::JSON.decode(value)&.symbolize_keys
  sanitized = sanitize_input(decoded)
  CONTENT_STRUCT.new(**sanitized)
end

#serialize(value) ⇒ Object



38
39
40
# File 'app/models/rails_live_dashboard/types/request_content.rb', line 38

def serialize(value)
  ActiveSupport::JSON.encode(value)
end

#typeObject



23
24
25
# File 'app/models/rails_live_dashboard/types/request_content.rb', line 23

def type
  :jsonb
end