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.
442 443 444 445 446 447 448 |
# File 'lib/mockserver/models.rb', line 442 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.
440 441 442 |
# File 'lib/mockserver/models.rb', line 440 def not_body @not_body end |
#operation_name ⇒ Object
Returns the value of attribute operation_name.
440 441 442 |
# File 'lib/mockserver/models.rb', line 440 def operation_name @operation_name end |
#optional ⇒ Object
Returns the value of attribute optional.
440 441 442 |
# File 'lib/mockserver/models.rb', line 440 def optional @optional end |
#query ⇒ Object
Returns the value of attribute query.
440 441 442 |
# File 'lib/mockserver/models.rb', line 440 def query @query end |
#variables_schema ⇒ Object
Returns the value of attribute variables_schema.
440 441 442 |
# File 'lib/mockserver/models.rb', line 440 def variables_schema @variables_schema end |
Class Method Details
.from_hash(data) ⇒ Object
459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/mockserver/models.rb', line 459 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
450 451 452 453 454 455 456 457 |
# File 'lib/mockserver/models.rb', line 450 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 |