Class: ActiveSupport::Messages::Metadata
- Defined in:
- lib/active_support/messages/metadata.rb
Overview
:nodoc:
Class Method Summary collapse
- .verify(message, purpose) ⇒ Object
- .wrap(message, expires_at: nil, expires_in: nil, purpose: nil) ⇒ Object
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(message, expires_at = nil, purpose = nil) ⇒ Metadata
constructor
A new instance of Metadata.
- #verify(purpose) ⇒ Object
Constructor Details
#initialize(message, expires_at = nil, purpose = nil) ⇒ Metadata
Returns a new instance of Metadata.
8 9 10 |
# File 'lib/active_support/messages/metadata.rb', line 8 def initialize(, expires_at = nil, purpose = nil) @message, @expires_at, @purpose = , expires_at, purpose end |
Class Method Details
.verify(message, purpose) ⇒ Object
25 26 27 |
# File 'lib/active_support/messages/metadata.rb', line 25 def verify(, purpose) ().verify(purpose) end |
.wrap(message, expires_at: nil, expires_in: nil, purpose: nil) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/active_support/messages/metadata.rb', line 17 def wrap(, expires_at: nil, expires_in: nil, purpose: nil) if expires_at || expires_in || purpose JSON.encode new(encode(), pick_expiry(expires_at, expires_in), purpose) else end end |
Instance Method Details
#as_json(options = {}) ⇒ Object
12 13 14 |
# File 'lib/active_support/messages/metadata.rb', line 12 def as_json( = {}) { _rails: { message: @message, exp: @expires_at, pur: @purpose } } end |
#verify(purpose) ⇒ Object
57 58 59 |
# File 'lib/active_support/messages/metadata.rb', line 57 def verify(purpose) @message if match?(purpose) && fresh? end |