Class: MockServer::JsonRpcBody
- Inherits:
-
Object
- Object
- MockServer::JsonRpcBody
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#not_body ⇒ Object
Returns the value of attribute not_body.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#params_schema ⇒ Object
Returns the value of attribute params_schema.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method_name:, params_schema: nil, not_body: false, optional: false) ⇒ JsonRpcBody
constructor
A new instance of JsonRpcBody.
- #to_h ⇒ Object
Constructor Details
#initialize(method_name:, params_schema: nil, not_body: false, optional: false) ⇒ JsonRpcBody
Returns a new instance of JsonRpcBody.
432 433 434 435 436 437 |
# File 'lib/mockserver/models.rb', line 432 def initialize(method_name:, params_schema: nil, not_body: false, optional: false) @method_name = method_name @params_schema = params_schema @not_body = not_body @optional = optional end |
Instance Attribute Details
#method_name ⇒ Object
Returns the value of attribute method_name.
430 431 432 |
# File 'lib/mockserver/models.rb', line 430 def method_name @method_name end |
#not_body ⇒ Object
Returns the value of attribute not_body.
430 431 432 |
# File 'lib/mockserver/models.rb', line 430 def not_body @not_body end |
#optional ⇒ Object
Returns the value of attribute optional.
430 431 432 |
# File 'lib/mockserver/models.rb', line 430 def optional @optional end |
#params_schema ⇒ Object
Returns the value of attribute params_schema.
430 431 432 |
# File 'lib/mockserver/models.rb', line 430 def params_schema @params_schema end |
Class Method Details
.from_hash(data) ⇒ Object
447 448 449 450 451 452 453 454 455 456 |
# File 'lib/mockserver/models.rb', line 447 def self.from_hash(data) return nil if data.nil? new( method_name: data['method'] || '', params_schema: data['paramsSchema'], not_body: data.fetch('not', false), optional: data.fetch('optional', false) ) end |
Instance Method Details
#to_h ⇒ Object
439 440 441 442 443 444 445 |
# File 'lib/mockserver/models.rb', line 439 def to_h result = { 'type' => 'JSON_RPC', 'method' => @method_name } result['paramsSchema'] = @params_schema if @params_schema result['not'] = true if @not_body result['optional'] = true if @optional result end |