Class: Arcp::Lease::LeaseConstraints

Inherits:
Data
  • Object
show all
Defined in:
lib/arcp/lease.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#expires_atObject (readonly)

Returns the value of attribute expires_at

Returns:

  • (Object)

    the current value of expires_at



11
12
13
# File 'lib/arcp/lease.rb', line 11

def expires_at
  @expires_at
end

#max_budgetObject (readonly)

Returns the value of attribute max_budget

Returns:

  • (Object)

    the current value of max_budget



11
12
13
# File 'lib/arcp/lease.rb', line 11

def max_budget
  @max_budget
end

Class Method Details

.from_h(h) ⇒ Object



12
13
14
15
16
17
# File 'lib/arcp/lease.rb', line 12

def self.from_h(h)
  return nil if h.nil?

  h = h.transform_keys(&:to_s)
  new(expires_at: h['expires_at'], max_budget: h['max_budget'])
end

Instance Method Details

#to_hObject



19
20
21
22
23
24
# File 'lib/arcp/lease.rb', line 19

def to_h
  out = {}
  out['expires_at'] = expires_at if expires_at
  out['max_budget'] = max_budget if max_budget
  out
end

#validate!Object



26
27
28
29
30
31
# File 'lib/arcp/lease.rb', line 26

def validate!
  return if expires_at.nil?

  t = Time.iso8601(expires_at)
  raise Arcp::Errors::InvalidRequest, "expires_at must be UTC (use 'Z'): #{expires_at}" unless t.utc?
end