Module: Loginator::JsonableStruct
Overview
Makes a Struct easily serializable and deserializable. Adds the from_json class method and to_json instance method to Struct classes.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#to_json ⇒ Object
(also: #to_s)
:rubocop:enable documentation.
Class Method Details
.included(base) ⇒ Object
8 9 10 |
# File 'lib/loginator/jsonable_struct.rb', line 8 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#to_json ⇒ Object Also known as: to_s
:rubocop:enable documentation
35 36 37 |
# File 'lib/loginator/jsonable_struct.rb', line 35 def to_json MultiJson.dump(to_h.merge(type: self.class.type)) end |