Class: Sad::Payload
- Inherits:
-
Object
- Object
- Sad::Payload
- Defined in:
- lib/sad/payload.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#klass ⇒ Object
Returns the value of attribute klass.
Class Method Summary collapse
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(klass, args) ⇒ Payload
constructor
A new instance of Payload.
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
#args ⇒ Object
Returns the value of attribute args.
3 4 5 |
# File 'lib/sad/payload.rb', line 3 def args @args end |
#klass ⇒ Object
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
#encode ⇒ Object
10 11 12 13 14 15 |
# File 'lib/sad/payload.rb', line 10 def encode { 'klass' => @klass, 'args' => @args }.to_json end |