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.
412 413 414 415 416 417 |
# File 'lib/mockserver/models.rb', line 412 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.
410 411 412 |
# File 'lib/mockserver/models.rb', line 410 def method_name @method_name end |
#not_body ⇒ Object
Returns the value of attribute not_body.
410 411 412 |
# File 'lib/mockserver/models.rb', line 410 def not_body @not_body end |
#optional ⇒ Object
Returns the value of attribute optional.
410 411 412 |
# File 'lib/mockserver/models.rb', line 410 def optional @optional end |
#params_schema ⇒ Object
Returns the value of attribute params_schema.
410 411 412 |
# File 'lib/mockserver/models.rb', line 410 def params_schema @params_schema end |
Class Method Details
.from_hash(data) ⇒ Object
427 428 429 430 431 432 433 434 435 436 |
# File 'lib/mockserver/models.rb', line 427 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
419 420 421 422 423 424 425 |
# File 'lib/mockserver/models.rb', line 419 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 |