module ActiveModel::Serializer::IncludeTree::Parsing

def include_args_to_hash(included)

Returns:
  • (Hash) - a Hash representing the same tree structure

Parameters:
  • included (Symbol, Hash, Array, String) --
def include_args_to_hash(included)
  case included
  when Symbol
    { included => {} }
  when Hash
    included.each_with_object({}) do |(key, value), hash|
      hash[key] = include_args_to_hash(value)
    end
  when Array
    included.reduce({}) { |a, e| a.deep_merge!(include_args_to_hash(e)) }
  when String
    include_string_to_hash(included)
  else
    {}
  end
end