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.



300
301
302
303
304
# File 'lib/mockserver/models.rb', line 300

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.



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

def time_to_live
  @time_to_live
end

#time_unitObject

Returns the value of attribute time_unit.



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

def time_unit
  @time_unit
end

#unlimitedObject

Returns the value of attribute unlimited.



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

def unlimited
  @unlimited
end

Class Method Details

.exactly(time_to_live, time_unit) ⇒ Object



328
329
330
331
332
333
334
# File 'lib/mockserver/models.rb', line 328

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



314
315
316
317
318
319
320
321
322
# File 'lib/mockserver/models.rb', line 314

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



324
325
326
# File 'lib/mockserver/models.rb', line 324

def self.unlimited
  new(unlimited: true)
end

Instance Method Details

#to_hObject



306
307
308
309
310
311
312
# File 'lib/mockserver/models.rb', line 306

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