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.



892
893
894
895
896
897
# File 'lib/mockserver/models.rb', line 892

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.



890
891
892
# File 'lib/mockserver/models.rb', line 890

def delay
  @delay
end

#drop_connectionObject

Returns the value of attribute drop_connection.



890
891
892
# File 'lib/mockserver/models.rb', line 890

def drop_connection
  @drop_connection
end

#primaryObject

Returns the value of attribute primary.



890
891
892
# File 'lib/mockserver/models.rb', line 890

def primary
  @primary
end

#response_bytesObject

Returns the value of attribute response_bytes.



890
891
892
# File 'lib/mockserver/models.rb', line 890

def response_bytes
  @response_bytes
end

Class Method Details

.errorObject



919
920
921
# File 'lib/mockserver/models.rb', line 919

def self.error
  new
end

.from_hash(data) ⇒ Object



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

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



899
900
901
902
903
904
905
906
# File 'lib/mockserver/models.rb', line 899

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