grape-entity-include 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +33 -6
- data/grape-entity-include.gemspec +2 -3
- data/lib/grape_entity_include/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f94b97387b74c936a9de7b562ea2c3442e54410ef30e533fe18c2af29a4d11c
|
4
|
+
data.tar.gz: d3839ff29d4602764d0059ef3a50197d9dba9d83277266a946eb93e75bd0424e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94c539753884d9b41b96a95507812cc18dbb065a8f203daf0c20c38e53340f4d6008f6b288e175673dcae07baf40224c9ae772baf1a0c581717d1789f50074f3
|
7
|
+
data.tar.gz: 9352f477bfceac7a98ce7944c106c44067e99c24d354171664b4e6cb599d12c8c4a845ba158682ec87a9b2ec6856c6d240f86cb26174a45772e58cac65c96d7f
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# GrapeEntityInclude
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
An include option for grape-entity, expose attributes if matching with attr_path option by using `include_attr_path?` method
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,36 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
Assume that you already had grape entities that sit on top of object models.
|
24
|
+
|
25
|
+
### Example
|
26
|
+
```ruby
|
27
|
+
UserEntity.represent(user_model, include: [:friends, { posts: [:comments, :photos] }])
|
28
|
+
|
29
|
+
class UserEntity < Grape::Entity
|
30
|
+
expose :name
|
31
|
+
expose :email
|
32
|
+
expose :friends, using: UserEntity, if: include_attr_path?
|
33
|
+
expose :posts, using: PostEntity, if: include_attr_path?
|
34
|
+
end
|
35
|
+
|
36
|
+
class PostEntity < Grape::Entity
|
37
|
+
expose :title
|
38
|
+
expose :content
|
39
|
+
expose :comments, using: CommentEntity, if: include_attr_path?
|
40
|
+
expose :photos, using: PhotoEntity, if: include_attr_path?
|
41
|
+
end
|
42
|
+
|
43
|
+
class CommentEntity < Grape::Entity
|
44
|
+
expose :content
|
45
|
+
end
|
46
|
+
|
47
|
+
class PhotoEntity < Grape::Entity
|
48
|
+
expose :caption
|
49
|
+
expose :url
|
50
|
+
end
|
51
|
+
|
52
|
+
```
|
26
53
|
|
27
54
|
## Development
|
28
55
|
|
@@ -32,7 +59,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
59
|
|
33
60
|
## Contributing
|
34
61
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ntd63t/grape-entity-include. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ntd63t/grape-entity-include/blob/master/CODE_OF_CONDUCT.md).
|
36
63
|
|
37
64
|
|
38
65
|
## License
|
@@ -41,4 +68,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
41
68
|
|
42
69
|
## Code of Conduct
|
43
70
|
|
44
|
-
Everyone interacting in the GrapeEntityInclude project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
71
|
+
Everyone interacting in the GrapeEntityInclude project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ntd63t/grape-entity-include/blob/master/CODE_OF_CONDUCT.md).
|
@@ -5,11 +5,10 @@ Gem::Specification.new do |spec|
|
|
5
5
|
spec.authors = ["Dzung Nguyen"]
|
6
6
|
spec.email = ["ntd63t@gmail.com"]
|
7
7
|
|
8
|
-
spec.summary = %q{grape-entity
|
9
|
-
spec.description = %q{grape-entity
|
8
|
+
spec.summary = %q{An include option for grape-entity, expose attributes if matching with attr_path option}
|
9
|
+
spec.description = %q{An include option for grape-entity, expose attributes if matching with attr_path option}
|
10
10
|
spec.homepage = "https://github.com/ntd63t/grape-entity-include.git"
|
11
11
|
spec.license = "MIT"
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
12
|
|
14
13
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
15
14
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-entity-include
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dzung Nguyen
|
@@ -38,7 +38,8 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description: grape-entity
|
41
|
+
description: An include option for grape-entity, expose attributes if matching with
|
42
|
+
attr_path option
|
42
43
|
email:
|
43
44
|
- ntd63t@gmail.com
|
44
45
|
executables: []
|
@@ -73,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
74
|
requirements:
|
74
75
|
- - ">="
|
75
76
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
77
|
+
version: '0'
|
77
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
79
|
requirements:
|
79
80
|
- - ">="
|
@@ -83,5 +84,6 @@ requirements: []
|
|
83
84
|
rubygems_version: 3.1.2
|
84
85
|
signing_key:
|
85
86
|
specification_version: 4
|
86
|
-
summary: grape-entity
|
87
|
+
summary: An include option for grape-entity, expose attributes if matching with attr_path
|
88
|
+
option
|
87
89
|
test_files: []
|