Method: WowzaRest::Data::Base#to_h
- Defined in:
- lib/wowza_rest/data/base.rb
#to_h ⇒ Object Also known as: to_hash
rubocop:disable Metrics/MethodLength
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wowza_rest/data/base.rb', line 40 def to_h instance_variables.each_with_object({}) do |var, hash| value = instance_variable_get(var) hash[send("#{var.to_s.delete('@')}_key")] = if value.is_a?(WowzaRest::Data::Base) instance_variable_get(var).to_h elsif value.is_a?(Array) if block_given? yield(var, instance_variable_get(var)) else objects_array_to_hash_array(instance_variable_get(var)) end else instance_variable_get(var) end end end |