Module: WCC::API::ActiveRecordShim::InstanceMethods

Defined in:
lib/wcc/api/active_record_shim.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/wcc/api/active_record_shim.rb', line 8

def attributes
  raw.keys.each_with_object({}) do |key, h|
    next unless respond_to?(key)

    val = public_send(key)
    h[key] =
      if val.is_a? Array
        val.map { |v| v.respond_to?(:to_h) ? v.to_h : v }
      else
        val.respond_to?(:to_h) ? val.to_h : val
      end
  end
end