Class: IssueSerializer

Inherits:
BaseSerializer show all
Defined in:
app/serializers/issue_serializer.rb

Instance Attribute Summary

Attributes inherited from BaseSerializer

#params

Instance Method Summary collapse

Methods inherited from BaseSerializer

entity, #initialize

Constructor Details

This class inherits a constructor from BaseSerializer

Instance Method Details

#choose_entity(opts) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/serializers/issue_serializer.rb', line 13

def choose_entity(opts)
  case opts[:serializer]
  when 'sidebar'
    IssueSidebarBasicEntity
  when 'sidebar_extras'
    IssueSidebarExtrasEntity
  when 'board'
    IssueBoardEntity
  else
    IssueEntity
  end
end

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

This overrided method takes care of which entity should be used to serialize the issue based on serializer key in opts param. Hence, entity doesn’t need to be declared on the class scope.



7
8
9
10
11
# File 'app/serializers/issue_serializer.rb', line 7

def represent(issue, opts = {})
  entity = choose_entity(opts)

  super(issue, opts, entity)
end