Module: Hashup

Included in:
HabiticaClient::Task, HabiticaClient::User::Stats
Defined in:
lib/hashup.rb

Instance Method Summary collapse

Instance Method Details

#hashup(*attributes) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/hashup.rb', line 3

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