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

Allow dynamic keys via as: proc #265

Merged
merged 7 commits into from
Apr 5, 2017
Merged

Conversation

james2m
Copy link
Contributor

@james2m james2m commented Apr 5, 2017

This adds the ability to specify keys dynamically in the expose as: using a proc. This uses the syntax as preferred by @dblock in #172

  object = OpenStruct(awesomness: 'awesome_key', awesome: 'not-my-key' )

  class MyEntity < Grape::Entity
    expose :awesome, as: -> { object.awesomness }
  end

  => { 'awesome_key': 'not-my-key' }

I've included #264 as it made seeing the wood for the trees easier when testing.

@LeFnord
Copy link
Member

LeFnord commented Apr 5, 2017

thanks @james2m … I prefer to first finish #264 and mörge it, then this one, ok?

@james2m
Copy link
Contributor Author

james2m commented Apr 5, 2017

@LeFnord Of course.

@james2m
Copy link
Contributor Author

james2m commented Apr 5, 2017

@LeFnord I'll rebase this when #264 is merged so you can see the wood for the trees.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 92.72% when pulling 68baab0 on james2m:dynamic-keys into 0930f60 on ruby-grape:master.

@james2m
Copy link
Contributor Author

james2m commented Apr 5, 2017

@LeFnord done, I'll stop fiddling now.

@LeFnord LeFnord merged commit ba229f8 into ruby-grape:master Apr 5, 2017
@james2m james2m deleted the dynamic-keys branch April 7, 2017 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants