Class: Taskflow::CustomHash
- Inherits:
-
Object
- Object
- Taskflow::CustomHash
- Defined in:
- lib/taskflow/custom_hash.rb
Class Method Summary collapse
Class Method Details
.dump(obj) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/taskflow/custom_hash.rb', line 7 def dump(obj) return unless obj unless obj.is_a?(HashWithIndifferentAccess) || obj.is_a?(Hash) raise ::ActiveRecord::SerializationTypeMismatch, "Attribute was supposed to be a Hash, but was a #{obj.class}. -- #{obj.inspect}" end JSON.dump obj end |
.load(str) ⇒ Object
3 4 5 6 |
# File 'lib/taskflow/custom_hash.rb', line 3 def load(str) return unless str HashWithIndifferentAccess.new JSON.parse(str) end |