Class: Scjson::Types::CancelProps
- Inherits:
-
Object
- Object
- Scjson::Types::CancelProps
- Defined in:
- lib/scjson/types.rb
Overview
cancel a pending ‘<send>` operation.
Instance Attribute Summary collapse
-
#other_attributes ⇒ Object
Returns the value of attribute other_attributes.
-
#other_element ⇒ Object
Returns the value of attribute other_element.
-
#sendid ⇒ Object
Returns the value of attribute sendid.
-
#sendidexpr ⇒ Object
Returns the value of attribute sendidexpr.
Class Method Summary collapse
-
.from_hash(data) ⇒ CancelProps
Build an instance from a Hash representation.
-
.from_json(json) ⇒ CancelProps
Deserialize an instance from a JSON payload.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ CancelProps
constructor
Instantiate a new CancelProps object.
-
#to_hash ⇒ Hash
Convert the object to a Hash suitable for JSON serialization.
-
#to_json(*opts) ⇒ String
Serialize the object to JSON.
Constructor Details
#initialize(**kwargs) ⇒ CancelProps
Instantiate a new CancelProps object.
293 294 295 296 297 298 |
# File 'lib/scjson/types.rb', line 293 def initialize(**kwargs) @other_element = kwargs.fetch(:other_element, []) @sendid = kwargs.fetch(:sendid, nil) @sendidexpr = kwargs.fetch(:sendidexpr, nil) @other_attributes = kwargs.fetch(:other_attributes, {}) end |
Instance Attribute Details
#other_attributes ⇒ Object
Returns the value of attribute other_attributes.
290 291 292 |
# File 'lib/scjson/types.rb', line 290 def other_attributes @other_attributes end |
#other_element ⇒ Object
Returns the value of attribute other_element.
290 291 292 |
# File 'lib/scjson/types.rb', line 290 def other_element @other_element end |
#sendid ⇒ Object
Returns the value of attribute sendid.
290 291 292 |
# File 'lib/scjson/types.rb', line 290 def sendid @sendid end |
#sendidexpr ⇒ Object
Returns the value of attribute sendidexpr.
290 291 292 |
# File 'lib/scjson/types.rb', line 290 def sendidexpr @sendidexpr end |
Class Method Details
.from_hash(data) ⇒ CancelProps
Build an instance from a Hash representation.
303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/scjson/types.rb', line 303 def self.from_hash(data) raise ArgumentError, 'Expected Hash' unless data.is_a?(Hash) normalized = data.transform_keys(&:to_s) kwargs = {} kwargs[:other_element] = Array(normalized.fetch('other_element', [])) kwargs[:sendid] = normalized.fetch('sendid', nil) kwargs[:sendidexpr] = normalized.fetch('sendidexpr', nil) kwargs[:other_attributes] = normalized.fetch('other_attributes', {}) new(**kwargs) end |
.from_json(json) ⇒ CancelProps
Deserialize an instance from a JSON payload.
318 319 320 321 |
# File 'lib/scjson/types.rb', line 318 def self.from_json(json) parsed = JSON.parse(json) from_hash(parsed) end |
Instance Method Details
#to_hash ⇒ Hash
Convert the object to a Hash suitable for JSON serialization.
325 326 327 328 329 330 331 332 |
# File 'lib/scjson/types.rb', line 325 def to_hash { 'other_element' => @other_element, 'sendid' => @sendid, 'sendidexpr' => @sendidexpr, 'other_attributes' => @other_attributes } end |
#to_json(*opts) ⇒ String
Serialize the object to JSON.
337 338 339 |
# File 'lib/scjson/types.rb', line 337 def to_json(*opts) JSON.generate(to_hash, *opts) end |