Module: Loginator::JsonableStruct::ClassMethods
- Defined in:
- lib/loginator/jsonable_struct.rb
Overview
class level mixins
Instance Method Summary collapse
Instance Method Details
#from_json(json) ⇒ Object
:nodoc
14 15 16 17 18 19 |
# File 'lib/loginator/jsonable_struct.rb', line 14 def from_json(json) json_type = json.delete('type') fail(ArgumentError, format('Incorrect message type: %s', json_type)) unless json_type == type fail(ArgumentError, format('Hash must contain keys: %s', members.join(', '))) unless valid_hash?(json) new(*json.values) end |
#type ⇒ Object
21 22 23 |
# File 'lib/loginator/jsonable_struct.rb', line 21 def type @type ||= name.split('::').last.downcase.freeze end |