Class: Kward::PluginResult
- Inherits:
-
Object
- Object
- Kward::PluginResult
- Defined in:
- lib/kward/plugins/actions.rb
Overview
Structured frontend and RPC result returned by typed commands and actions.
Instance Attribute Summary collapse
- #data ⇒ Object readonly
- #message ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message: nil, data: nil) ⇒ PluginResult
constructor
A new instance of PluginResult.
- #to_h ⇒ Object
Constructor Details
#initialize(message: nil, data: nil) ⇒ PluginResult
Returns a new instance of PluginResult.
356 357 358 359 360 |
# File 'lib/kward/plugins/actions.rb', line 356 def initialize(message: nil, data: nil) @message = .nil? ? nil : .to_s @data = normalize_json(data) freeze end |
Instance Attribute Details
#data ⇒ Object (readonly)
347 348 349 |
# File 'lib/kward/plugins/actions.rb', line 347 def data @data end |
#message ⇒ Object (readonly)
347 348 349 |
# File 'lib/kward/plugins/actions.rb', line 347 def @message end |
Class Method Details
.wrap(value) ⇒ Object
349 350 351 352 353 354 |
# File 'lib/kward/plugins/actions.rb', line 349 def self.wrap(value) return value if value.is_a?(self) return new if value.nil? new(message: value.to_s) end |
Instance Method Details
#to_h ⇒ Object
362 363 364 |
# File 'lib/kward/plugins/actions.rb', line 362 def to_h { message: , data: data }.compact end |