grape-roar
grape-roar copied to clipboard
Lookup Representers Dynamically
Would you consider adding support for automatically extending object
with the appropriate representer and releasing this as a gem?
Say something along these lines of:
def call(object, env)
representer_name = "#{object.class}Representer"
if Object.const_definied?(representer_name)
representer_class = Object.const_get()
object.extend(representer_class)
end
Grape::Formatter::Json.call object, env
end