rails-domino 0.2.0 → 0.2.2
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/lib/domino/generators/domino/templates/blueprint.rb.tt +2 -2
- data/lib/domino/generators/domino/templates/controller.rb.tt +7 -7
- data/lib/domino/generators/domino/templates/repository.rb.tt +13 -13
- data/lib/domino/generators/domino/templates/service.rb.tt +8 -8
- data/lib/domino/version.rb +1 -1
- data/lib/rails-domino.rb +3 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a1c94e573fad8d3380e40712a13a10c0c67d9cf71e093542d9f37fd5bb393b1
|
4
|
+
data.tar.gz: ac7dc2e8733b94828f4e2ac00a124d70cb12efddd356d83c10cb59cf3792fa20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 800d1297aab8aa402f037da89d2bd223d379286c74be23a677be0d50fafe8af985fbc9b41ed3eab63f4d9093e00a084151a5de2919e1808df7dab9d4da482dcf
|
7
|
+
data.tar.gz: 118980448544a544c99de7d40e0cc3e7d04165f0cf96a212e077c7f38764cc1552b5bec7055d7b57e9c0ac6c6945b7ccc8e0b1c6f76924d3f016c2f5e0af6ef5
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# Blueprint for serializing <%=
|
1
|
+
# Blueprint for serializing <%= @model_name %> model.
|
2
2
|
#
|
3
3
|
# @see https://github.com/procore/blueprinter
|
4
4
|
#
|
5
|
-
class <%=
|
5
|
+
class <%= @model_name %>Blueprint < Blueprinter::Base
|
6
6
|
identifier :id
|
7
7
|
|
8
8
|
# Fields to expose
|
@@ -1,28 +1,28 @@
|
|
1
|
-
# Controller for <%=
|
1
|
+
# Controller for <%= @model_name.pluralize %> API endpoints.
|
2
2
|
#
|
3
|
-
# Provides RESTful actions for <%=
|
3
|
+
# Provides RESTful actions for <%= @model_name %> resources.
|
4
4
|
#
|
5
|
-
class <%=
|
5
|
+
class <%= @model_name.pluralize %>Controller < ApplicationController
|
6
6
|
include Import['<%= file_name %>_service']
|
7
7
|
|
8
8
|
# GET /<%= file_name.pluralize %>
|
9
9
|
# @return [JSON]
|
10
10
|
def index
|
11
|
-
render json: <%=
|
11
|
+
render json: <%= @model_name %>Blueprint.render(@<%= file_name %>_service.all)
|
12
12
|
end
|
13
13
|
|
14
14
|
# GET /<%= file_name.pluralize %>/:id
|
15
15
|
# @param id [Integer]
|
16
16
|
# @return [JSON]
|
17
17
|
def show
|
18
|
-
render json: <%=
|
18
|
+
render json: <%= @model_name %>Blueprint.render(@<%= file_name %>_service.get(params[:id]))
|
19
19
|
end
|
20
20
|
|
21
21
|
# POST /<%= file_name.pluralize %>
|
22
22
|
# @return [JSON]
|
23
23
|
def create
|
24
24
|
obj = @<%= file_name %>_service.create(user_params)
|
25
|
-
render json: <%=
|
25
|
+
render json: <%= @model_name %>Blueprint.render(obj), status: :created
|
26
26
|
end
|
27
27
|
|
28
28
|
# PUT/PATCH /<%= file_name.pluralize %>/:id
|
@@ -30,7 +30,7 @@ class <%= class_name.pluralize %>Controller < ApplicationController
|
|
30
30
|
# @return [JSON]
|
31
31
|
def update
|
32
32
|
obj = @<%= file_name %>_service.update(params[:id], user_params)
|
33
|
-
render json: <%=
|
33
|
+
render json: <%= @model_name %>Blueprint.render(obj)
|
34
34
|
end
|
35
35
|
|
36
36
|
# DELETE /<%= file_name %>/:id
|
@@ -1,42 +1,42 @@
|
|
1
|
-
# Repository for <%=
|
1
|
+
# Repository for <%= @model_name %> model.
|
2
2
|
#
|
3
3
|
# Provides abstracted access to ActiveRecord persistence.
|
4
4
|
#
|
5
5
|
# @example
|
6
|
-
# repo = <%=
|
6
|
+
# repo = <%= @model_name %>Repository.new
|
7
7
|
# repo.find_by_id(1)
|
8
8
|
#
|
9
|
-
class <%=
|
9
|
+
class <%= @model_name %>Repository < BaseRepository
|
10
10
|
# @param id [Integer]
|
11
|
-
# @return [<%=
|
11
|
+
# @return [<%= @model_name %>, nil]
|
12
12
|
def find_by_id(id)
|
13
|
-
<%=
|
13
|
+
<%= @model_name %>.find_by(id: id)
|
14
14
|
end
|
15
15
|
|
16
|
-
# @return [Array<<%=
|
16
|
+
# @return [Array<<%= @model_name %>>]
|
17
17
|
def all
|
18
|
-
<%=
|
18
|
+
<%= @model_name %>.all
|
19
19
|
end
|
20
20
|
|
21
21
|
# @param attrs [Hash]
|
22
|
-
# @return [<%=
|
22
|
+
# @return [<%= @model_name %>]
|
23
23
|
def create(attrs)
|
24
|
-
<%=
|
24
|
+
<%= @model_name %>.create(attrs)
|
25
25
|
end
|
26
26
|
|
27
27
|
# @param id [Integer]
|
28
28
|
# @param attrs [Hash]
|
29
|
-
# @return [<%=
|
29
|
+
# @return [<%= @model_name %>, nil]
|
30
30
|
def update(id, attrs)
|
31
|
-
record = <%=
|
31
|
+
record = <%= @model_name %>.find_by(id: id)
|
32
32
|
record.update(attrs) if record
|
33
33
|
record
|
34
34
|
end
|
35
35
|
|
36
36
|
# @param id [Integer]
|
37
|
-
# @return [<%=
|
37
|
+
# @return [<%= @model_name %>, nil]
|
38
38
|
def delete(id)
|
39
|
-
record = <%=
|
39
|
+
record = <%= @model_name %>.find_by(id: id)
|
40
40
|
record&.destroy
|
41
41
|
end
|
42
42
|
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
# Service for business logic around <%=
|
1
|
+
# Service for business logic around <%= @model_name %>.
|
2
2
|
#
|
3
3
|
# Handles use-case orchestration and business operations.
|
4
4
|
#
|
5
5
|
# @example
|
6
|
-
# service = <%=
|
6
|
+
# service = <%= @model_name %>Service.new(...)
|
7
7
|
# service.get(1)
|
8
8
|
#
|
9
|
-
class <%=
|
9
|
+
class <%= @model_name %>Service < BaseService
|
10
10
|
include Import['<%= file_name %>_repository']
|
11
11
|
|
12
|
-
# @param <%= file_name %>_repository [<%=
|
12
|
+
# @param <%= file_name %>_repository [<%= @model_name %>Repository]
|
13
13
|
def initialize(<%= file_name %>_repository:)
|
14
14
|
@<%= file_name %>_repository = <%= file_name %>_repository
|
15
15
|
end
|
16
16
|
|
17
17
|
# @param id [Integer]
|
18
|
-
# @return [<%=
|
18
|
+
# @return [<%= @model_name %>, nil]
|
19
19
|
def get(id)
|
20
20
|
@<%= file_name %>_repository.find_by_id(id)
|
21
21
|
end
|
22
22
|
|
23
23
|
# @param attrs [Hash]
|
24
|
-
# @return [<%=
|
24
|
+
# @return [<%= @model_name %>]
|
25
25
|
def create(attrs)
|
26
26
|
@<%= file_name %>_repository.create(attrs)
|
27
27
|
end
|
28
28
|
|
29
29
|
# @param id [Integer]
|
30
30
|
# @param attrs [Hash]
|
31
|
-
# @return [<%=
|
31
|
+
# @return [<%= @model_name %>, nil]
|
32
32
|
def update(id, attrs)
|
33
33
|
@<%= file_name %>_repository.update(id, attrs)
|
34
34
|
end
|
@@ -39,7 +39,7 @@ class <%= class_name %>Service < BaseService
|
|
39
39
|
!!@<%= file_name %>_repository.delete(id)
|
40
40
|
end
|
41
41
|
|
42
|
-
# @return [Array<<%=
|
42
|
+
# @return [Array<<%= @model_name %>>]
|
43
43
|
def all
|
44
44
|
@<%= file_name %>_repository.all
|
45
45
|
end
|
data/lib/domino/version.rb
CHANGED
data/lib/rails-domino.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-domino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kiebor81
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/domino/generators/domino/templates/service.rb.tt
|
97
97
|
- lib/domino/scaffolder.rb
|
98
98
|
- lib/domino/version.rb
|
99
|
+
- lib/rails-domino.rb
|
99
100
|
homepage: https://github.com/kiebor81/rails-domino
|
100
101
|
licenses:
|
101
102
|
- MIT
|