steeeve/habitica_client

View on GitHub
lib/hashup.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Hashup

  def hashup(*attributes)
    define_method(:to_h) do

      kv = attributes.map { |k| [k, send(k)] }
                     .delete_if { |_k, v| v.nil? }

      Hash[kv]

    end
  end

end