Skip to content

Conversation

@drn
Copy link
Member

@drn drn commented Feb 5, 2019

In addition to object, the entity options are available to access via this attr_reader

Some context -

We had a PR with logic in it that looked like:

# .../api.rb class Api resources ... do get '...' do present resource, with: ....Entity, variant: params[:variant] end end end # .../...entity.rb class ...Entity expose :html do |_, options| @variant = options[:variant] html end private def html ...FetchHtml.call(resource: resource, variant: @variant)` end end 

Instead of:

# .../...entity.rb class ...Entity expose :html private def html ...FetchHtml.call(resource: resource, variant: options[:variant])` end end 

The concern with using options directly was that it wasn't documented.

I didn't update the CHANGELOG since this is just a README update.

@grape-bot
Copy link

1 Error
🚫 One of the lines below found in CHANGELOG.md doesn’t match the expected format. Please make it look like the other lines, pay attention to periods and spaces.
1 Warning
⚠️ Unless you’re refactoring existing code, please update CHANGELOG.md.

Here's an example of a CHANGELOG.md entry:

* [#316](https://github.com/ruby-grape/grape-entity/pull/316): Add options usage notes to readme - [@drn](https://github.com/drn).
* [#258](https://github.com/ruby-grape/grape-entity/pull/307): Allow exposures to call methods defined in modules included in an entity [@robertoz-01](https://github.com/robertoz-01).

Generated by 🚫 danger

@grape-bot
Copy link

grape-bot commented Feb 5, 2019

1 Error
🚫 One of the lines below found in CHANGELOG.md doesn’t match the expected format. Please make it look like the other lines, pay attention to periods and spaces.
1 Warning
⚠️ Unless you’re refactoring existing code, please update CHANGELOG.md.
* [#258](https://github.com/ruby-grape/grape-entity/pull/307): Allow exposures to call methods defined in modules included in an entity [@robertoz-01](https://github.com/robertoz-01).

Here's an example of a CHANGELOG.md entry:

* [#316](https://github.com/ruby-grape/grape-entity/pull/316): Add options usage notes to readme - [@drn](https://github.com/drn).

Generated by 🚫 danger

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.11% when pulling 530667a on drn:options-readme into 4529077 on ruby-grape:master.

@LeFnord
Copy link
Member

LeFnord commented Feb 5, 2019

thanks @drn

@LeFnord LeFnord merged commit 05d743b into ruby-grape:master Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants