Sha256: 4999284888a22c3f2660b3dc938d4bd019091c0b6fb2941f805f133173eaa995
Contents?: true
Size: 590 Bytes
Versions: 1
Compression:
Stored size: 590 Bytes
Contents
module Separatum module Converters class Object2Hash def call(*objects) objects.map do |object| klass = object.class.respond_to?(:name) ? object.class.name : object.class.to_s if object.respond_to?(:as_json) { _klass: klass }.merge(object.as_json) elsif object.respond_to?(:to_hash) { _klass: klass }.merge(object.to_hash) elsif object.respond_to?(:to_h) { _klass: klass }.merge(object.to_h) else fail(object.inspect) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
separatum-0.1.0 | lib/separatum/converters/object2_hash.rb |