grape-utils 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/grape_utils/templates/create.rb +1 -1
- data/lib/grape_utils/templates/crud.rb +3 -1
- data/lib/grape_utils/templates/delete.rb +1 -1
- data/lib/grape_utils/templates/index.rb +4 -2
- data/lib/grape_utils/templates/show.rb +1 -1
- data/lib/grape_utils/templates/update.rb +1 -1
- data/lib/grape_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79b7322f38d4726c6dda0cd99b7571c6029559f1d2e906415d15e7418dbb14ce
|
4
|
+
data.tar.gz: 91682d99f941d9a558170ac0a05723cf10debc0ce0c32df423e02776027b8751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 960027819b0ea29704faf2c0c96339d3c6c64e00980a258f4beccdb20037cefe9fd07726e05463bba30ac4b385aa3adcba4b6281e6f00214c18f088f7f61266f
|
7
|
+
data.tar.gz: af5c2f21ace9343a42d072f530fd57c8996299f58e4009dc996f26e44e336f5ee34d6526a61990eaf0c6d19c1565410c41d989e275f527e760bd75df8641b170
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -48,7 +48,7 @@ module AwesomeAPI
|
|
48
48
|
class Foo < Base
|
49
49
|
|
50
50
|
resource :foos do
|
51
|
-
mount Grape::Utils::Templates::Index, with: { index: Foo.all, entity: Entities::Foo }
|
51
|
+
mount Grape::Utils::Templates::Index, with: { model: Foo, index: Foo.all, entity: Entities::Foo }
|
52
52
|
mount Grape::Utils::Templates::Show, with: { model: Foo, entity: Entities::Foo }
|
53
53
|
mount Grape::Utils::Templates::Create, with: { model: Foo, entity: Entities::Foo}
|
54
54
|
mount Grape::Utils::Templates::Update, with: { model: Foo.all, entity: Entities::Foo }
|
@@ -8,7 +8,7 @@ module Grape
|
|
8
8
|
helpers Grape::Utils::Helpers
|
9
9
|
|
10
10
|
mounted do
|
11
|
-
desc "Creates an instance of #{configuration[:model].
|
11
|
+
desc "Creates an instance of #{configuration[:model].name}"
|
12
12
|
params do
|
13
13
|
requires :none, except: configuration[:required_params],
|
14
14
|
using: configuration[:entity].documentation
|
@@ -6,7 +6,9 @@ module Grape
|
|
6
6
|
# Adds all requests necessary to CRUD the resource
|
7
7
|
class Crud < ::Grape::API
|
8
8
|
mounted do
|
9
|
-
mount Templates::Index, with: {
|
9
|
+
mount Templates::Index, with: { model: configuration[:model],
|
10
|
+
index: configuration[:index],
|
11
|
+
entity: configuration[:entity] }
|
10
12
|
|
11
13
|
mount Templates::Create, with: { model: configuration[:model],
|
12
14
|
entity: configuration[:entity],
|
@@ -9,7 +9,7 @@ module Grape
|
|
9
9
|
|
10
10
|
mounted do
|
11
11
|
route_param :id, type: String do
|
12
|
-
desc "Deletes an instances of #{configuration[:model].
|
12
|
+
desc "Deletes an instances of #{configuration[:model].name}"
|
13
13
|
delete do
|
14
14
|
resource = configuration[:model].find_by!((configuration[:column_id] || :id) => params[:id])
|
15
15
|
resource.destroy!
|
@@ -11,12 +11,14 @@ module Grape
|
|
11
11
|
helpers Grape::Utils::Helpers
|
12
12
|
|
13
13
|
mounted do
|
14
|
-
desc "Lists all #{configuration[:model].
|
14
|
+
desc "Lists all #{configuration[:model].name}"
|
15
15
|
params do
|
16
16
|
use :pagination, per_page: 10, max_per_page: 30
|
17
17
|
end
|
18
18
|
get do
|
19
|
-
|
19
|
+
index = configuration[:index]
|
20
|
+
|
21
|
+
list = index.is_a?(Proc) ? instance_eval(&index) : index
|
20
22
|
|
21
23
|
present list, with: configuration[:entity]
|
22
24
|
end
|
@@ -9,7 +9,7 @@ module Grape
|
|
9
9
|
|
10
10
|
mounted do
|
11
11
|
route_param :id, type: String do
|
12
|
-
desc "Details of a #{configuration[:model].
|
12
|
+
desc "Details of a #{configuration[:model].name}"
|
13
13
|
get do
|
14
14
|
resource = configuration[:model].find_by!((configuration[:column_id] || :id) => params[:id])
|
15
15
|
present resource, with: configuration[:entity]
|
data/lib/grape_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nix41
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|