Module: Hashify

Included in:
Worklog::DailyLog, Worklog::LogEntry
Defined in:
lib/hash.rb

Instance Method Summary collapse

Instance Method Details

#to_hashHash

Convert the object’s instance variables to a hash.

Returns:

  • (Hash)

    the hash representation of the object



6
7
8
9
10
11
# File 'lib/hash.rb', line 6

def to_hash
  instance_variables.each_with_object({}) do |var, hash|
    key = var.to_s.delete('@').to_sym
    hash[key] = instance_variable_get(var)
  end
end