Class: Serega::SeregaUtils::CollectionDetector
- Inherits:
-
Object
- Object
- Serega::SeregaUtils::CollectionDetector
- Defined in:
- lib/serega/utils/collection_detector.rb
Overview
Utility to check if an object should be serialized as a collection.
Hashes and Structs are Enumerable, but enumerate their own member values, so they are treated as single objects.
Class Method Summary collapse
-
.call(object) ⇒ Boolean
Checks if provided object is a collection of objects.
Class Method Details
.call(object) ⇒ Boolean
Checks if provided object is a collection of objects
22 23 24 |
# File 'lib/serega/utils/collection_detector.rb', line 22 def call(object) object.is_a?(Enumerable) && !object.is_a?(Hash) && !object.is_a?(Struct) end |