You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
*[#115](https://github.com/intridea/grape-entity/pull/115): Allowing 'root' to be inherited from parent to child entities - [@guidoprincess](https://github.com/guidoprincess).
*[#134](https://github.com/intridea/grape-entity/pull/134): Subclasses no longer affected in all cases by `unexpose` in parent - [@etehtsea](https://github.com/etehtsea).
Copy file name to clipboardExpand all lines: README.md
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -222,7 +222,7 @@ end
222
222
223
223
#### Returning only the fields you want
224
224
225
-
After exposing the desired attributes, you can choose which one you need when representing some object or collection, see the example:
225
+
After exposing the desired attributes, you can choose which one you need when representing some object or collection by using the only: and except: options. See the example:
226
226
227
227
```ruby
228
228
classUserEntity
@@ -237,7 +237,7 @@ class Entity
237
237
expose :user, using:UserEntity
238
238
end
239
239
240
-
data =Entity.represent(model, only: [:name, { user: [:name, :email] }])
240
+
data =Entity.represent(model, only: [:title, { user: [:name, :email] }])
241
241
data.as_json
242
242
```
243
243
@@ -256,7 +256,12 @@ This will return something like this:
256
256
Instead of returning all the exposed attributes.
257
257
258
258
259
+
The same result can be achieved with the following exposure:
259
260
261
+
```ruby
262
+
data =Entity.represent(model, except: [:id, { user: [:id] }])
0 commit comments