lib/mutils/serialization/serialization_results.rb in mutils-0.2.25 vs lib/mutils/serialization/serialization_results.rb in mutils-0.2.27

- old
+ new

@@ -3,14 +3,14 @@ # Module Mutils module Mutils module Serialization # Module SerializationResults module SerializationResults - def generate_hash if scope if scope_is_collection? + options[:child] = true scope.map { |inner_scope| self.class.new(inner_scope, options).generate_hash } else hashed_result end else @@ -78,8 +78,24 @@ end def scope_is_collection? scope.respond_to?(:size) && !scope.respond_to?(:each_pair) end + + def class_name + if scope_is_collection? + format_class_name(scope[0]).pluralize + else + format_class_name(scope) + end + end + + def format_class_name(object) + if self.class.serializer_name&.length&.positive? + self.class.serializer_name + else + object.class.to_s.downcase + end + end end end -end \ No newline at end of file +end