Class: EnvironmentSerializer

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

Defined Under Namespace

Classes: Item

Instance Attribute Summary

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 Method Details

#itemized?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'app/serializers/environment_serializer.rb', line 14

def itemized?
  @itemize
end

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


18
19
20
21
22
23
24
25
26
27
28
# File 'app/serializers/environment_serializer.rb', line 18

def represent(resource, opts = {})
  if itemized?
    itemize(resource).map do |item|
      { name: item.name,
        size: item.size,
        latest: super(item.latest, opts) }
    end
  else
    super(resource, opts)
  end
end

#within_foldersObject


10
11
12
# File 'app/serializers/environment_serializer.rb', line 10

def within_folders
  tap { @itemize = true }
end