Class: EventQ::SerializationProviders::JsonSerializationProvider
- Inherits:
-
Object
- Object
- EventQ::SerializationProviders::JsonSerializationProvider
- Defined in:
- lib/eventq_base/serialization_providers/json_serialization_provider.rb
Instance Method Summary collapse
- #deserialize(json) ⇒ Object
-
#initialize ⇒ JsonSerializationProvider
constructor
A new instance of JsonSerializationProvider.
- #serialize(object) ⇒ Object
Constructor Details
#initialize ⇒ JsonSerializationProvider
Returns a new instance of JsonSerializationProvider.
5 6 7 8 9 10 |
# File 'lib/eventq_base/serialization_providers/json_serialization_provider.rb', line 5 def initialize require 'class_kit' require 'hash_kit' @class_kit_helper = ClassKit::Helper.new @hash_helper = HashKit::Helper.new end |
Instance Method Details
#deserialize(json) ⇒ Object
16 17 18 |
# File 'lib/eventq_base/serialization_providers/json_serialization_provider.rb', line 16 def deserialize(json) return @class_kit_helper.from_json(json: json, klass: EventQ::QueueMessage) end |
#serialize(object) ⇒ Object
12 13 14 |
# File 'lib/eventq_base/serialization_providers/json_serialization_provider.rb', line 12 def serialize(object) JSON.dump(object_to_hash(object)) end |