Sha256: 201d0fa44be3f31355e9ab7fc3801ff5a4477ca71b6a3fd7469b165cd2a6b8b4

Contents?: true

Size: 557 Bytes

Versions: 9

Compression:

Stored size: 557 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

9 entries across 9 versions & 1 rubygems

Version Path
licensee-9.18.0 lib/licensee/hash_helper.rb
licensee-9.17.1 lib/licensee/hash_helper.rb
licensee-9.17.0 lib/licensee/hash_helper.rb
licensee-9.16.1 lib/licensee/hash_helper.rb
licensee-9.16.0 lib/licensee/hash_helper.rb
licensee-9.15.3 lib/licensee/hash_helper.rb
licensee-9.15.2 lib/licensee/hash_helper.rb
licensee-9.15.1 lib/licensee/hash_helper.rb
licensee-9.15.0 lib/licensee/hash_helper.rb