Skip to content

Commit 7365266

Browse files
committed
Merge pull request #158 from tyre/patch-1
Copy changes in README
2 parents abefb7f + 183d596 commit 7365266

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ present s, with: Status, user: current_user
311311
```
312312

313313
#### Passing Additional Option To Nested Exposure
314-
There are sometimes that you want to pass additional option or parameter to nested exposure. Assume that you need to expose an address for a contact info, but it has both two different format: **full** and **simple**. You can pass an additional `full_format` option to specify that if the nested entity should render address in `:full` format.
314+
Sometimes you want to pass additional options or parameters to nested a exposure. For example, let's say that you need to expose an address for a contact info and it has two different formats: **full** and **simple**. You can pass an additional `full_format` option to specify which format to render.
315315

316316
```ruby
317317
# api/contact.rb
@@ -332,21 +332,21 @@ expose :stree do |instance, options|
332332
!!options[:full_format] ? instance.full_street_name : instance.simple_street_name
333333
end
334334
```
335-
**Notice**: In the above code, you should pay attention to [**Safe Exposure**](#safe-exposure) yourself, for example, `instance.address` might be `nil`, in this situation, it is better to expose it as nil directly.
335+
**Notice**: In the above code, you should pay attention to [**Safe Exposure**](#safe-exposure) yourself. For example, `instance.address` might be `nil` and it is better to expose it as nil directly.
336336

337337
#### Attribute Path Tracking
338338

339-
Sometimes, especially when there are nested attributes, you might want to know which attribute it
340-
is being exposed. For example, some APIs allow user provide a parameter to control which fields
339+
Sometimes, especially when there are nested attributes, you might want to know which attribute
340+
is being exposed. For example, some APIs allow users to provide a parameter to control which fields
341341
will be included in (or excluded from) the response.
342342

343-
Grape entity can track the path of each attribute, then you could access it during condition check
344-
or runtime exposure, via `options[:attr_path]`.
343+
GrapeEntity can track the path of each attribute, which you can access during conditions checking
344+
or runtime exposure via `options[:attr_path]`.
345345

346-
Attribute path is an array. The last item of this array is the name (alias) of current attribute.
347-
And if the attribute is nested, the former items are names (aliases) of its ancestor attributes.
346+
The attribute path is an array. The last item of this array is the name (alias) of current attribute.
347+
If the attribute is nested, the former items are names (aliases) of its ancestor attributes.
348348

349-
Here is an example shows what the attribute path will be.
349+
Example:
350350

351351
```ruby
352352
class Status < Grape::Entity

0 commit comments

Comments
 (0)