Class: Maxwell::Agent::Host::Service::Serializer

Inherits:
Object
  • Object
show all
Includes:
Coercable
Defined in:
lib/maxwell/agent/host/service.rb

Class Method Summary collapse

Methods included from Coercable

#coerce_value, #coerce_values!, included

Class Method Details

.deserialize(json) ⇒ Object



27
28
29
30
# File 'lib/maxwell/agent/host/service.rb', line 27

def self.deserialize(json)
  hash = JSON.parse(json, symbolize_names: true)
  Service.new(new.coerce_values!(hash))
end

.serialize(attrs) ⇒ Object



21
22
23
24
25
# File 'lib/maxwell/agent/host/service.rb', line 21

def self.serialize(attrs)
  attrs.last_run   = attrs.last_run.to_s if attrs.last_run
  attrs.perform_at = attrs.perform_at.to_s if attrs.perform_at
  JSON.dump attrs
end