Sha256: 48aa5788373e12059ef96bf57d2cc9bf54f179e7e803e0cf279f536f59bb7268

Contents?: true

Size: 454 Bytes

Versions: 10

Compression:

Stored size: 454 Bytes

Contents

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

10 entries across 10 versions & 1 rubygems

Version Path
licensee-9.11.0 lib/licensee/hash_helper.rb
licensee-9.10.1 lib/licensee/hash_helper.rb
licensee-9.10.0 lib/licensee/hash_helper.rb
licensee-9.9.4 lib/licensee/hash_helper.rb
licensee-9.9.3 lib/licensee/hash_helper.rb
licensee-9.9.2 lib/licensee/hash_helper.rb
licensee-9.9.1 lib/licensee/hash_helper.rb
licensee-9.9.0 lib/licensee/hash_helper.rb
licensee-9.9.0.beta.3 lib/licensee/hash_helper.rb
licensee-9.9.0.beta.2 lib/licensee/hash_helper.rb