Class: Sad::Payload

Inherits:
Object
  • Object
show all
Defined in:
lib/sad/payload.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, args) ⇒ Payload

Returns a new instance of Payload.



5
6
7
8
# File 'lib/sad/payload.rb', line 5

def initialize(klass, args)
	@klass = klass
	@args = args
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



3
4
5
# File 'lib/sad/payload.rb', line 3

def args
  @args
end

#klassObject

Returns the value of attribute klass.



3
4
5
# File 'lib/sad/payload.rb', line 3

def klass
  @klass
end

Class Method Details

.decode(json) ⇒ Object



17
18
19
20
# File 'lib/sad/payload.rb', line 17

def self.decode(json)
	h = JSON.parse(json)
	self.new(h['klass'], h['args'])
end

Instance Method Details

#encodeObject



10
11
12
13
14
15
# File 'lib/sad/payload.rb', line 10

def encode
	{
		'klass' => @klass,
		'args' => @args
	}.to_json
end