Module: ActiveResource::Formats

Defined in:
lib/active_resource/formats_ext.rb

Class Method Summary collapse

Class Method Details

.remove_root(data) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/active_resource/formats_ext.rb', line 3

def self.remove_root(data)
  begin
    data = data.with_indifferent_access
    data = data.key?(:data) ? data[:data] : data
  rescue
  end

  p "### Formats ###"
  pp data

  if data.is_a?(Hash) && data.keys.size == 1 && data.values.first.is_a?(Enumerable)
    data.values.first
  else
    data
  end
end