Class: MockServer::GraphQLBody
- Inherits:
-
Object
- Object
- MockServer::GraphQLBody
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#not_body ⇒ Object
Returns the value of attribute not_body.
-
#operation_name ⇒ Object
Returns the value of attribute operation_name.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#query ⇒ Object
Returns the value of attribute query.
-
#variables_schema ⇒ Object
Returns the value of attribute variables_schema.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(query:, operation_name: nil, variables_schema: nil, not_body: false, optional: false) ⇒ GraphQLBody
constructor
A new instance of GraphQLBody.
- #to_h ⇒ Object
Constructor Details
#initialize(query:, operation_name: nil, variables_schema: nil, not_body: false, optional: false) ⇒ GraphQLBody
Returns a new instance of GraphQLBody.
462 463 464 465 466 467 468 |
# File 'lib/mockserver/models.rb', line 462 def initialize(query:, operation_name: nil, variables_schema: nil, not_body: false, optional: false) @query = query @operation_name = operation_name @variables_schema = variables_schema @not_body = not_body @optional = optional end |
Instance Attribute Details
#not_body ⇒ Object
Returns the value of attribute not_body.
460 461 462 |
# File 'lib/mockserver/models.rb', line 460 def not_body @not_body end |
#operation_name ⇒ Object
Returns the value of attribute operation_name.
460 461 462 |
# File 'lib/mockserver/models.rb', line 460 def operation_name @operation_name end |
#optional ⇒ Object
Returns the value of attribute optional.
460 461 462 |
# File 'lib/mockserver/models.rb', line 460 def optional @optional end |
#query ⇒ Object
Returns the value of attribute query.
460 461 462 |
# File 'lib/mockserver/models.rb', line 460 def query @query end |
#variables_schema ⇒ Object
Returns the value of attribute variables_schema.
460 461 462 |
# File 'lib/mockserver/models.rb', line 460 def variables_schema @variables_schema end |
Class Method Details
.from_hash(data) ⇒ Object
479 480 481 482 483 484 485 486 487 488 489 |
# File 'lib/mockserver/models.rb', line 479 def self.from_hash(data) return nil if data.nil? new( query: data['query'] || '', operation_name: data['operationName'], variables_schema: data['variablesSchema'], not_body: data.fetch('not', false), optional: data.fetch('optional', false) ) end |
Instance Method Details
#to_h ⇒ Object
470 471 472 473 474 475 476 477 |
# File 'lib/mockserver/models.rb', line 470 def to_h result = { 'type' => 'GRAPHQL', 'query' => @query } result['operationName'] = @operation_name if @operation_name result['variablesSchema'] = @variables_schema if @variables_schema result['not'] = true if @not_body result['optional'] = true if @optional result end |