tramway-api 0.4.1 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/tramway/api/v1/application_controller.rb +0 -2
- data/app/controllers/tramway/api/v1/records_controller.rb +29 -0
- data/app/serializers/tramway/api/v1/application_serializer.rb +11 -0
- data/config/routes.rb +1 -0
- data/lib/tramway/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d30f1034ddf1ce117031c4938dd22976165f3e14aedbe7dc88b8e4e17101db0
|
4
|
+
data.tar.gz: 136d87b0dc8ac562d8e77615b8fa25a633ec8413efbfd6e641338ade3c9195df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8525c1cbae56ac1b2825fdaae66952557f671eb741837c7c9e2d17fd3c6e97e3e7f24a49a5aaba893a90845e623685f041d79a9a22d7a27c8a58cef2b95375bf
|
7
|
+
data.tar.gz: 720f689c3538cdc4c0aed15ff8d22b42ba28ca75c4219fef8922ae90cc719abaa473812864f111e19f3eb5c289ed6d9325965e9fc6a91328b6ecf29a514f91d5
|
@@ -7,5 +7,34 @@ module Tramway::Api::V1
|
|
7
7
|
each_serializer: serializer,
|
8
8
|
status: :ok
|
9
9
|
end
|
10
|
+
|
11
|
+
def create
|
12
|
+
record_form = form_class.new model_class.new
|
13
|
+
if record_form.submit params[:data][:attributes]
|
14
|
+
render json: record_form.model,
|
15
|
+
serializer: serializer_class,
|
16
|
+
status: :created
|
17
|
+
else
|
18
|
+
render_errors_for record_form
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def model_class
|
25
|
+
params[:model].constantize
|
26
|
+
end
|
27
|
+
|
28
|
+
def decorator_class(model_name = nil)
|
29
|
+
"#{model_name || model_class}Decorator".constantize
|
30
|
+
end
|
31
|
+
|
32
|
+
def form_class(model_name = nil)
|
33
|
+
"#{model_name || model_class}Form".constantize
|
34
|
+
end
|
35
|
+
|
36
|
+
def serializer_class(model_name = nil)
|
37
|
+
"#{model_name || model_class}Serializer".constantize
|
38
|
+
end
|
10
39
|
end
|
11
40
|
end
|
data/config/routes.rb
CHANGED
data/lib/tramway/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: knock
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- app/jobs/tramway/api/application_job.rb
|
73
73
|
- app/mailers/tramway/api/application_mailer.rb
|
74
74
|
- app/models/tramway/api/application_record.rb
|
75
|
+
- app/serializers/tramway/api/v1/application_serializer.rb
|
75
76
|
- app/serializers/tramway/api/v1/error_serializer.rb
|
76
77
|
- app/views/layouts/tramway/api/application.html.erb
|
77
78
|
- config/initializers/active_model_serializers.rb
|