Sha256: 88ff4eb3330adb1bf01511a5c45985a165c0fda00a3f92db2e6ebf5755ddea96
Contents?: true
Size: 545 Bytes
Versions: 5
Compression:
Stored size: 545 Bytes
Contents
# frozen_string_literal: true module Licensee module HashHelper def to_h hash = {} self.class::HASH_METHODS.each do |method| key = method.to_s.delete('?').to_sym value = public_send(method) hash[key] = if value.is_a?(Array) value.map { |v| v.respond_to?(:to_h) ? v.to_h : v } elsif value.respond_to?(:to_h) && !value.nil? value.to_h else value end end hash end end end
Version data entries
5 entries across 5 versions & 1 rubygems