grape-entity-include 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 388d153790f67d185d5f1fc9296a8f555d441bc027b6787c99bdccf2f9f961ae
4
- data.tar.gz: 50273b099a0bf619605d84728af8d3bcf737e5ea56b0bd84b37a305b2a082793
3
+ metadata.gz: 8f94b97387b74c936a9de7b562ea2c3442e54410ef30e533fe18c2af29a4d11c
4
+ data.tar.gz: d3839ff29d4602764d0059ef3a50197d9dba9d83277266a946eb93e75bd0424e
5
5
  SHA512:
6
- metadata.gz: 58a92c4de0996a254522e132be9c49e3179f7cc7c22657ae9d2c2c29b7e147b51528e8d02cf0f4d711759c67c23d8996451fd543c50318a1d40548d43ac63951
7
- data.tar.gz: 0fdeae85c239c92cf4cf2c25f517ee1420c1e1960e9f4fc209c9710fb463a4e66aa59ac7030365c525eefd6fd751e091dba6bde59fe9b77cafbdd1ba60a4937f
6
+ metadata.gz: 94c539753884d9b41b96a95507812cc18dbb065a8f203daf0c20c38e53340f4d6008f6b288e175673dcae07baf40224c9ae772baf1a0c581717d1789f50074f3
7
+ data.tar.gz: 9352f477bfceac7a98ce7944c106c44067e99c24d354171664b4e6cb599d12c8c4a845ba158682ec87a9b2ec6856c6d240f86cb26174a45772e58cac65c96d7f
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # GrapeEntityInclude
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/grape/entity/include`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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/[USERNAME]/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/[USERNAME]/grape-entity-include/blob/master/CODE_OF_CONDUCT.md).
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/[USERNAME]/grape-entity-include/blob/master/CODE_OF_CONDUCT.md).
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-include}
9
- spec.description = %q{grape-entity-include}
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
 
@@ -1,3 +1,3 @@
1
1
  module GrapeEntityInclude
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-include
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: 2.3.0
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-include
87
+ summary: An include option for grape-entity, expose attributes if matching with attr_path
88
+ option
87
89
  test_files: []