Class: GroupChildSerializer

Inherits:
BaseSerializer show all
Includes:
WithPagination
Defined in:
app/serializers/group_child_serializer.rb

Instance Attribute Summary collapse

Attributes included from WithPagination

#paginator

Attributes inherited from BaseSerializer

#params

Instance Method Summary collapse

Methods included from WithPagination

#paginated?, #with_pagination

Methods inherited from BaseSerializer

entity, #initialize

Constructor Details

This class inherits a constructor from BaseSerializer

Instance Attribute Details

#hierarchy_rootObject (readonly)

Returns the value of attribute hierarchy_root.



6
7
8
# File 'app/serializers/group_child_serializer.rb', line 6

def hierarchy_root
  @hierarchy_root
end

#should_expand_hierarchyObject (readonly)

Returns the value of attribute should_expand_hierarchy.



6
7
8
# File 'app/serializers/group_child_serializer.rb', line 6

def should_expand_hierarchy
  @should_expand_hierarchy
end

Instance Method Details

#expand_hierarchy(hierarchy_root = nil) ⇒ Object



10
11
12
13
14
15
# File 'app/serializers/group_child_serializer.rb', line 10

def expand_hierarchy(hierarchy_root = nil)
  @hierarchy_root = hierarchy_root
  @should_expand_hierarchy = true

  self
end

#represent(resource, opts = {}, entity_class = nil) ⇒ Object



17
18
19
20
21
22
23
24
# File 'app/serializers/group_child_serializer.rb', line 17

def represent(resource, opts = {}, entity_class = nil)
  if should_expand_hierarchy
    paginator.paginate(resource) if paginated?
    represent_hierarchies(resource, opts)
  else
    super(resource, opts)
  end
end