Module: Property::Serialization::JSON::Validator
- Defined in:
- lib/property/serialization/json.rb
Constant Summary collapse
- NATIVE_TYPES =
[Hash, Array, Integer, Float, String, TrueClass, FalseClass, NilClass]
Class Method Summary collapse
-
.validate(klass) ⇒ Object
Should raise an exception if the type is not serializable.
Class Method Details
.validate(klass) ⇒ Object
Should raise an exception if the type is not serializable.
13 14 15 16 17 18 19 20 |
# File 'lib/property/serialization/json.rb', line 13 def self.validate(klass) if NATIVE_TYPES.include?(klass) || (klass.respond_to?(:json_create) && klass.instance_methods.include?(:to_json)) true else raise TypeError.new("Cannot serialize #{klass}. Missing 'self.create_json' and 'to_json' methods.") end end |