Class: MockServer::TimeToLive

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(time_unit: nil, time_to_live: nil, unlimited: nil) ⇒ TimeToLive

Returns a new instance of TimeToLive.



297
298
299
300
301
# File 'lib/mockserver/models.rb', line 297

def initialize(time_unit: nil, time_to_live: nil, unlimited: nil)
  @time_unit = time_unit
  @time_to_live = time_to_live
  @unlimited = unlimited
end

Instance Attribute Details

#time_to_liveObject

Returns the value of attribute time_to_live.



295
296
297
# File 'lib/mockserver/models.rb', line 295

def time_to_live
  @time_to_live
end

#time_unitObject

Returns the value of attribute time_unit.



295
296
297
# File 'lib/mockserver/models.rb', line 295

def time_unit
  @time_unit
end

#unlimitedObject

Returns the value of attribute unlimited.



295
296
297
# File 'lib/mockserver/models.rb', line 295

def unlimited
  @unlimited
end

Class Method Details

.exactly(time_to_live, time_unit) ⇒ Object



325
326
327
328
329
330
331
# File 'lib/mockserver/models.rb', line 325

def self.exactly(time_to_live, time_unit)
  new(
    time_unit:    time_unit,
    time_to_live: time_to_live,
    unlimited:    false
  )
end

.from_hash(data) ⇒ Object



311
312
313
314
315
316
317
318
319
# File 'lib/mockserver/models.rb', line 311

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

  new(
    time_unit:    data['timeUnit'],
    time_to_live: data['timeToLive'],
    unlimited:    data['unlimited']
  )
end

.unlimitedObject



321
322
323
# File 'lib/mockserver/models.rb', line 321

def self.unlimited
  new(unlimited: true)
end

Instance Method Details

#to_hObject



303
304
305
306
307
308
309
# File 'lib/mockserver/models.rb', line 303

def to_h
  MockServer.strip_none({
    'timeUnit'   => @time_unit,
    'timeToLive' => @time_to_live,
    'unlimited'  => @unlimited
  })
end