2016-10-28 08:32:07 -04:00
|
|
|
class BaseSerializer
|
2016-11-03 07:54:10 -04:00
|
|
|
def initialize(parameters = {})
|
|
|
|
@request = EntityRequest.new(parameters)
|
2016-10-28 08:32:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def represent(resource, opts = {})
|
2016-11-04 10:00:39 -04:00
|
|
|
self.class.entity_class
|
|
|
|
.represent(resource, opts.merge(request: @request))
|
2017-01-27 07:02:59 -05:00
|
|
|
.as_json
|
2016-10-28 08:32:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.entity(entity_class)
|
|
|
|
@entity_class ||= entity_class
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.entity_class
|
|
|
|
@entity_class
|
|
|
|
end
|
|
|
|
end
|