Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup Representers Dynamically #1

Open
johnallen3d opened this issue Aug 23, 2013 · 4 comments
Open

Lookup Representers Dynamically #1

johnallen3d opened this issue Aug 23, 2013 · 4 comments

Comments

@johnallen3d
Copy link

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
@dblock
Copy link
Member

dblock commented Aug 26, 2013

That could work, yes.

@johnallen3d
Copy link
Author

Cool, I was thinking about it a little more over the weekend and it possible you'd want to have pluralized versions of representers as well. I'll work something up and submit a pull request. Thanks.

@dblock dblock changed the title Lookup Representers Dynamically? Lookup Representers Dynamically Jul 23, 2014
@thisiscab
Copy link

Is there any progress on this?

@johnallen3d
Copy link
Author

Sorry, I've not been working roar of late and haven't gotten back to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants