Class: MockServer::HttpError

Inherits:
Object
  • Object
show all
Defined in:
lib/mockserver/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(drop_connection: nil, response_bytes: nil, delay: nil, primary: nil) ⇒ HttpError

Returns a new instance of HttpError.



912
913
914
915
916
917
# File 'lib/mockserver/models.rb', line 912

def initialize(drop_connection: nil, response_bytes: nil, delay: nil, primary: nil)
  @drop_connection = drop_connection
  @response_bytes = response_bytes
  @delay = delay
  @primary = primary
end

Instance Attribute Details

#delayObject

Returns the value of attribute delay.



910
911
912
# File 'lib/mockserver/models.rb', line 910

def delay
  @delay
end

#drop_connectionObject

Returns the value of attribute drop_connection.



910
911
912
# File 'lib/mockserver/models.rb', line 910

def drop_connection
  @drop_connection
end

#primaryObject

Returns the value of attribute primary.



910
911
912
# File 'lib/mockserver/models.rb', line 910

def primary
  @primary
end

#response_bytesObject

Returns the value of attribute response_bytes.



910
911
912
# File 'lib/mockserver/models.rb', line 910

def response_bytes
  @response_bytes
end

Class Method Details

.errorObject



939
940
941
# File 'lib/mockserver/models.rb', line 939

def self.error
  new
end

.from_hash(data) ⇒ Object



928
929
930
931
932
933
934
935
936
937
# File 'lib/mockserver/models.rb', line 928

def self.from_hash(data)
  return nil if data.nil?

  new(
    drop_connection: data['dropConnection'],
    response_bytes:  data['responseBytes'],
    delay:           Delay.from_hash(data['delay']),
    primary:         data['primary']
  )
end

Instance Method Details

#to_hObject



919
920
921
922
923
924
925
926
# File 'lib/mockserver/models.rb', line 919

def to_h
  MockServer.strip_none({
    'dropConnection' => @drop_connection,
    'responseBytes'  => @response_bytes,
    'delay'          => @delay&.to_h,
    'primary'        => @primary
  })
end