Class: LinkIO::PendingLinkData
- Inherits:
-
Object
- Object
- LinkIO::PendingLinkData
- Defined in:
- lib/linkio/pending_link_data.rb
Overview
A deep link stored for later retrieval (deferred deep linking). Timestamps are epoch milliseconds, matching the Node.js backend so that data is interchangeable between the two implementations.
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.from_h(hash) ⇒ PendingLinkData
Build from a hash using either camelCase (JSON/Node-compatible) or snake_case keys.
Instance Method Summary collapse
- #expired?(now_ms = (Time.now.to_f * 1000).to_i) ⇒ Boolean
-
#initialize(url:, params:, created_at:, expires_at:) ⇒ PendingLinkData
constructor
A new instance of PendingLinkData.
- #to_h ⇒ Hash
Constructor Details
#initialize(url:, params:, created_at:, expires_at:) ⇒ PendingLinkData
Returns a new instance of PendingLinkData.
14 15 16 17 18 19 |
# File 'lib/linkio/pending_link_data.rb', line 14 def initialize(url:, params:, created_at:, expires_at:) @url = url @params = params || {} @created_at = created_at @expires_at = expires_at end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/linkio/pending_link_data.rb', line 8 def created_at @created_at end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
8 9 10 |
# File 'lib/linkio/pending_link_data.rb', line 8 def expires_at @expires_at end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/linkio/pending_link_data.rb', line 8 def params @params end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/linkio/pending_link_data.rb', line 8 def url @url end |
Class Method Details
.from_h(hash) ⇒ PendingLinkData
Build from a hash using either camelCase (JSON/Node-compatible) or snake_case keys.
42 43 44 45 46 47 48 49 50 |
# File 'lib/linkio/pending_link_data.rb', line 42 def self.from_h(hash) h = stringify(hash) new( url: h["url"], params: h["params"] || {}, created_at: h["createdAt"] || h["created_at"], expires_at: h["expiresAt"] || h["expires_at"] ) end |
Instance Method Details
#expired?(now_ms = (Time.now.to_f * 1000).to_i) ⇒ Boolean
23 24 25 |
# File 'lib/linkio/pending_link_data.rb', line 23 def expired?(now_ms = (Time.now.to_f * 1000).to_i) now_ms > expires_at end |
#to_h ⇒ Hash
28 29 30 31 32 33 34 35 |
# File 'lib/linkio/pending_link_data.rb', line 28 def to_h { "url" => url, "params" => params, "createdAt" => created_at, "expiresAt" => expires_at } end |