Class: Cloudflare::DurableObjectId
- Inherits:
-
Object
- Object
- Cloudflare::DurableObjectId
- Defined in:
- lib/cloudflare_workers/durable_object.rb
Overview
Wraps a JS DurableObjectId (opaque token returned by ‘namespace.idFromName(…)` / `namespace.newUniqueId()`). Carries the raw JS id so we can round-trip it into `namespace.get(id)`.
Instance Attribute Summary collapse
-
#js_id ⇒ Object
readonly
Returns the value of attribute js_id.
Instance Method Summary collapse
-
#initialize(js_id) ⇒ DurableObjectId
constructor
A new instance of DurableObjectId.
-
#to_s ⇒ Object
Hex string representation (stable across invocations for a named id).
Constructor Details
#initialize(js_id) ⇒ DurableObjectId
Returns a new instance of DurableObjectId.
62 63 64 |
# File 'lib/cloudflare_workers/durable_object.rb', line 62 def initialize(js_id) @js_id = js_id end |
Instance Attribute Details
#js_id ⇒ Object (readonly)
Returns the value of attribute js_id.
60 61 62 |
# File 'lib/cloudflare_workers/durable_object.rb', line 60 def js_id @js_id end |
Instance Method Details
#to_s ⇒ Object
Hex string representation (stable across invocations for a named id).
67 68 69 70 |
# File 'lib/cloudflare_workers/durable_object.rb', line 67 def to_s js = @js_id `(#{js} && typeof #{js}.toString === 'function' ? #{js}.toString() : String(#{js} || ''))` end |