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.
510 511 512 513 514 515 |
# File 'lib/mockserver/models.rb', line 510 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.
508 509 510 |
# File 'lib/mockserver/models.rb', line 508 def method_name @method_name end |
#not_body ⇒ Object
Returns the value of attribute not_body.
508 509 510 |
# File 'lib/mockserver/models.rb', line 508 def not_body @not_body end |
#optional ⇒ Object
Returns the value of attribute optional.
508 509 510 |
# File 'lib/mockserver/models.rb', line 508 def optional @optional end |
#params_schema ⇒ Object
Returns the value of attribute params_schema.
508 509 510 |
# File 'lib/mockserver/models.rb', line 508 def params_schema @params_schema end |
Class Method Details
.from_hash(data) ⇒ Object
525 526 527 528 529 530 531 532 533 534 |
# File 'lib/mockserver/models.rb', line 525 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
517 518 519 520 521 522 523 |
# File 'lib/mockserver/models.rb', line 517 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 |