Module: GraphQL::Subscriptions::Serialize Private
- Defined in:
- lib/graphql/subscriptions/serialize.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Serialization helpers for passing subscription data around.
Constant Summary collapse
- GLOBALID_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"__gid__"
- SYMBOL_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"__sym__"
- SYMBOL_KEYS_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"__sym_keys__"
- TIMESTAMP_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"__timestamp__"
- TIMESTAMP_FORMAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
eg '2020-01-01 23:59:59.123456789+05:00'
"%Y-%m-%d %H:%M:%S.%N%z"
- OPEN_STRUCT_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"__ostruct__"
Class Method Summary collapse
-
.dump(obj) ⇒ String
private
The stringified object.
-
.dump_recursive(obj) ⇒ String
private
This is for turning objects into subscription scopes.
-
.load(str) ⇒ Object
private
An object equivalent to the one passed to Serialize.dump.
Class Method Details
.dump(obj) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The stringified object.
28 29 30 |
# File 'lib/graphql/subscriptions/serialize.rb', line 28 def dump(obj) JSON.generate(dump_value(obj), quirks_mode: true) end |
.dump_recursive(obj) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is for turning objects into subscription scopes. It's a one-way transformation, can't reload this :'(
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/graphql/subscriptions/serialize.rb', line 36 def dump_recursive(obj) case when obj.is_a?(Array) obj.map { |i| dump_recursive(i) }.join(':') when obj.is_a?(Hash) obj.map { |k, v| "#{dump_recursive(k)}:#{dump_recursive(v)}" }.join(":") when obj.is_a?(GraphQL::Schema::InputObject) dump_recursive(obj.to_h) when obj.respond_to?(:to_gid_param) obj.to_gid_param when obj.respond_to?(:to_param) obj.to_param else obj.to_s end end |
.load(str) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns An object equivalent to the one passed to dump.
21 22 23 24 |
# File 'lib/graphql/subscriptions/serialize.rb', line 21 def load(str) parsed_obj = JSON.parse(str) load_value(parsed_obj) end |