Skip to content

Commit f4202b9

Browse files
committed
Merge pull request #144 from castillobg/namespace-refactor
Refactored examples namespacing.
2 parents 7ca35a4 + f78a589 commit f4202b9

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
@@ -23,13 +23,13 @@ module API
2323
expose :user_type, :user_id, if: lambda { |status, options| status.user.public? }
2424
expose :contact_info do
2525
expose :phone
26-
expose :address, using: API::Address
26+
expose :address, using: API::Entities::Address
2727
end
2828
expose :digest do |status, options|
2929
Digest::MD5.hexdigest status.txt
3030
end
31-
expose :replies, using: API::Status, as: :responses
32-
expose :last_reply, using: API::Status do |status, options|
31+
expose :replies, using: API::Entities::Status, as: :responses
32+
expose :last_reply, using: API::Entities::Status do |status, options|
3333
status.replies.last
3434
end
3535

@@ -78,13 +78,13 @@ The field lookup takes several steps
7878
Don't derive your model classes from `Grape::Entity`, expose them using a presenter.
7979

8080
```ruby
81-
expose :replies, using: API::Status, as: :responses
81+
expose :replies, using: API::Entities::Status, as: :responses
8282
```
8383

8484
Presenter classes can also be specified in string format, which helps with circular dependencies.
8585

8686
```ruby
87-
expose :replies, using: "API::Status", as: :responses
87+
expose :replies, using: "API::Entities::Status", as: :responses
8888
```
8989

9090
#### Conditional Exposure
@@ -116,15 +116,15 @@ Supply a block to define a hash using nested exposures.
116116
```ruby
117117
expose :contact_info do
118118
expose :phone
119-
expose :address, using: API::Address
119+
expose :address, using: API::Entities::Address
120120
end
121121
```
122122

123123
You can also conditionally expose attributes in nested exposures:
124124
```ruby
125125
expose :contact_info do
126126
expose :phone
127-
expose :address, using: API::Address
127+
expose :address, using: API::Entities::Address
128128
expose :email, if: lambda { |instance, options| options[:type] == :full }
129129
end
130130
```
@@ -268,7 +268,7 @@ data.as_json
268268
Expose under a different name with `:as`.
269269

270270
```ruby
271-
expose :replies, using: API::Status, as: :responses
271+
expose :replies, using: API::Entities::Status, as: :responses
272272
```
273273

274274
#### Format Before Exposing
@@ -319,7 +319,7 @@ expose :contact_info do
319319
expose :phone
320320
expose :address do |instance, options|
321321
# use `#merge` to extend options and then pass the new version of options to the nested entity
322-
API::Address.represent instance.address, options.merge(full_format: instance.need_full_format?)
322+
API::Entities::Address.represent instance.address, options.merge(full_format: instance.need_full_format?)
323323
end
324324
expose :email, if: lambda { |instance, options| options[:type] == :full }
325325
end

0 commit comments

Comments
 (0)