Class: ActiveSupport::MessagesMetadata
- Inherits:
-
Object
- Object
- ActiveSupport::MessagesMetadata
- Defined in:
- lib/active_storage/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) ⇒ MessagesMetadata
constructor
A new instance of MessagesMetadata.
- #verify(purpose) ⇒ Object
Constructor Details
#initialize(message, expires_at = nil, purpose = nil) ⇒ MessagesMetadata
Returns a new instance of MessagesMetadata.
2 3 4 |
# File 'lib/active_storage/messages_metadata.rb', line 2 def initialize(, expires_at = nil, purpose = nil) @message, @expires_at, @purpose = , expires_at, purpose end |
Class Method Details
.verify(message, purpose) ⇒ Object
19 20 21 |
# File 'lib/active_storage/messages_metadata.rb', line 19 def verify(, purpose) ().verify(purpose) end |
.wrap(message, expires_at: nil, expires_in: nil, purpose: nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/active_storage/messages_metadata.rb', line 11 def wrap(, expires_at: nil, expires_in: nil, purpose: nil) if expires_at || expires_in || purpose ActiveSupport::JSON.encode new(encode(), pick_expiry(expires_at, expires_in), purpose) else end end |
Instance Method Details
#as_json(options = {}) ⇒ Object
6 7 8 |
# File 'lib/active_storage/messages_metadata.rb', line 6 def as_json( = {}) { _rails: { message: @message, exp: @expires_at, pur: @purpose } } end |
#verify(purpose) ⇒ Object
51 52 53 |
# File 'lib/active_storage/messages_metadata.rb', line 51 def verify(purpose) @message if match?(purpose) && fresh? end |