BigW Consortium Gitlab

base_serializer.rb 363 Bytes
Newer Older
1
class BaseSerializer
2 3
  def initialize(parameters = {})
    @request = EntityRequest.new(parameters)
4 5 6
  end

  def represent(resource, opts = {})
7 8
    self.class.entity_class
      .represent(resource, opts.merge(request: @request))
9 10 11 12 13 14 15 16 17 18
  end

  def self.entity(entity_class)
    @entity_class ||= entity_class
  end

  def self.entity_class
    @entity_class
  end
end