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

Version Path
licensee-9.14.1 lib/licensee/hash_helper.rb
licensee-9.14.0 lib/licensee/hash_helper.rb
licensee-9.13.2 lib/licensee/hash_helper.rb
licensee-9.13.1 lib/licensee/hash_helper.rb
licensee-9.13.0 lib/licensee/hash_helper.rb