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.
627 628 629 630 631 632 |
# File 'lib/mockserver/models.rb', line 627 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.
625 626 627 |
# File 'lib/mockserver/models.rb', line 625 def method_name @method_name end |
#not_body ⇒ Object
Returns the value of attribute not_body.
625 626 627 |
# File 'lib/mockserver/models.rb', line 625 def not_body @not_body end |
#optional ⇒ Object
Returns the value of attribute optional.
625 626 627 |
# File 'lib/mockserver/models.rb', line 625 def optional @optional end |
#params_schema ⇒ Object
Returns the value of attribute params_schema.
625 626 627 |
# File 'lib/mockserver/models.rb', line 625 def params_schema @params_schema end |
Class Method Details
.from_hash(data) ⇒ Object
642 643 644 645 646 647 648 649 650 651 |
# File 'lib/mockserver/models.rb', line 642 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
634 635 636 637 638 639 640 |
# File 'lib/mockserver/models.rb', line 634 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 |