Module: Coach4rb::Mixin::AsHash::InstanceMethods
- Defined in:
- lib/coach4rb/mixin/as_hash.rb
Instance Method Summary collapse
-
#to_hash ⇒ Object
(also: #to_h)
Converts this object to a hash.
Instance Method Details
#to_hash ⇒ Object Also known as: to_h
Converts this object to a hash.
16 17 18 19 20 21 22 23 24 |
# File 'lib/coach4rb/mixin/as_hash.rb', line 16 def to_hash variables = instance_variables hash = {} variables.each do |name| key = name.to_s.sub(/^@/, '') hash[key.to_sym] = instance_variable_get(name) end hash end |