Class: Messages::Metadata

Inherits:
Object show all
Defined in:
lib/brick.rb

Class Method Summary collapse

Class Method Details

.wrap(message, *args, expires_at: nil, expires_in: nil, purpose: nil) ⇒ Object



1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
# File 'lib/brick.rb', line 1849

def self.wrap(message, *args, expires_at: nil, expires_in: nil, purpose: nil)
  if args.last.is_a?(Hash)
    expires_at ||= args.last[:expires_at]
    expires_in ||= args.last[:expires_in]
    purpose ||= args.last[:purpose]
  end
  if expires_at || expires_in || purpose
    JSON.encode new(encode(message), pick_expiry(expires_at, expires_in), purpose)
  else
    message
  end
end