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
|
|
|
|
|
2017-05-09 00:15:34 -04:00
|
|
|
def represent(resource, opts = {}, entity_class = nil)
|
|
|
|
entity_class = entity_class || self.class.entity_class
|
|
|
|
|
|
|
|
entity_class
|
2016-11-04 10:00:39 -04:00
|
|
|
.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
|