Method: JSONAPI::Serializer.parse_relationship_paths

Defined in:
lib/jsonapi-serializers/serializer.rb

.parse_relationship_paths(paths) ⇒ Object

Takes a list of relationship paths and returns a hash as deep as the given paths. The _include: true is a sentinal value that specifies whether the parent level should be included.

Example:

Given: ['author', 'comments', 'comments.user']
Returns: {
  'author' => {_include: true},
  'comments' => {_include: true, 'user' => {_include: true}},
}


438
439
440
441
442
# File 'lib/jsonapi-serializers/serializer.rb', line 438

def self.parse_relationship_paths(paths)
  relationships = {}
  paths.each { |path| merge_relationship_path(path, relationships) }
  relationships
end