Class: CommandProposal::Service::JsonWrapper
- Inherits:
-
Object
- Object
- CommandProposal::Service::JsonWrapper
- Defined in:
- app/models/command_proposal/service/json_wrapper.rb
Class Method Summary collapse
-
.dump(obj) ⇒ Object
Allows directly setting pre-stringified JSON.
- .load(str) ⇒ Object
Class Method Details
.dump(obj) ⇒ Object
Allows directly setting pre-stringified JSON.
5 6 7 8 9 |
# File 'app/models/command_proposal/service/json_wrapper.rb', line 5 def self.dump(obj) return obj if obj.is_a?(String) JSON.dump(obj) end |
.load(str) ⇒ Object
11 12 13 14 15 |
# File 'app/models/command_proposal/service/json_wrapper.rb', line 11 def self.load(str) return {} unless str.present? JSON.parse(str).with_indifferent_access end |