class ActiveModel::Serializer::IncludeTree

TODO: description of this class, and overview of how it’s used

def self.from_include_args(included)

Returns:
  • (IncludeTree) -

Parameters:
  • included (Symbol, Hash, Array, String) --

Other tags:
    Example: `posts: [:author, comments: [:author, :upvotes]]` -
def self.from_include_args(included)
  return included if included.is_a?(IncludeTree)
  new(Parsing.include_args_to_hash(included))
end

def self.from_string(included)

Returns:
  • (IncludeTree) -

Parameters:
  • included (String) --

Other tags:
    Example: `'posts.author, posts.comments.upvotes, posts.comments.author'` -
def self.from_string(included)
  new(Parsing.include_string_to_hash(included))
end

def [](key)

def [](key)
  # TODO(beauby): Adopt a lazy caching strategy for generating subtrees.
  case
  when @hash.key?(key)
    self.class.new(@hash[key])
  when @hash.key?(:*)
    self.class.new(@hash[:*])
  when @hash.key?(:**)
    self.class.new(:** => {})
  else
    nil
  end
end

def initialize(hash = {})

Parameters:
  • hash (Hash) --
def initialize(hash = {})
  @hash = hash
end

def key?(key)

def key?(key)
  @hash.key?(key) || @hash.key?(:*) || @hash.key?(:**)
end