tramway-api 1.8.6.9 → 1.8.6.14
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f74bf7e6832d2bfb526269d6d1604618017598f124287da8fee292ba5c26f6e
|
4
|
+
data.tar.gz: b98eb65cfe16ba9be869e96dafcc57b3c3539ddf57f3bac76cf6f462aae333c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4923dd219e9c0cf859657fc9fe73634d39f0ec96f1bffc662ddf1c8e7c8c45cc0140101fb18f4485314c84174c39a4bf296c4cd8feab31c457896d14ba0612d1
|
7
|
+
data.tar.gz: f51b96cdf8bc331d0150a2039477bdad427aa56569b2c12e820bb69d1388fe0c7019ee0b2d92de9c2c8ba31569135c7c4446bbf7f0ce56a7a60e73712439cde9
|
@@ -6,9 +6,38 @@ module Tramway
|
|
6
6
|
include ::Knock::Authenticable
|
7
7
|
protect_from_forgery with: :null_session, if: proc { |c| c.request.format == 'application/json' }
|
8
8
|
rescue_from ActiveRecord::RecordNotFound, with: :not_found if Rails.env.production?
|
9
|
+
before_action :load_application
|
10
|
+
|
11
|
+
def load_application
|
12
|
+
if engine_loaded(request).present?
|
13
|
+
build_application_with_engine engine_loaded request
|
14
|
+
elsif application_class(request).present?
|
15
|
+
@application = application_class(request).camelize.constantize.first
|
16
|
+
else
|
17
|
+
@application = application_object request
|
18
|
+
end
|
19
|
+
end
|
9
20
|
|
10
21
|
private
|
11
22
|
|
23
|
+
def build_application_with_engine(engine_loaded)
|
24
|
+
engine_module = "::Tramway::#{engine_loaded.camelize}".constantize
|
25
|
+
@application = "#{engine_module}::#{engine_module.application.to_s.camelize}".constantize.first
|
26
|
+
@application_engine = engine_loaded
|
27
|
+
end
|
28
|
+
|
29
|
+
def application_class(request)
|
30
|
+
Constraints::DomainConstraint.new(request.domain).application_class
|
31
|
+
end
|
32
|
+
|
33
|
+
def engine_loaded(request)
|
34
|
+
Constraints::DomainConstraint.new(request.domain).engine_loaded
|
35
|
+
end
|
36
|
+
|
37
|
+
def application_object(request)
|
38
|
+
Constraints::DomainConstraint.new(request.domain).application_object
|
39
|
+
end
|
40
|
+
|
12
41
|
def not_found
|
13
42
|
render json: { data: [] }, status: :not_found
|
14
43
|
end
|
@@ -4,8 +4,6 @@ module Tramway
|
|
4
4
|
module Api
|
5
5
|
module V1
|
6
6
|
class ApplicationController < ::Tramway::Api::ApplicationController
|
7
|
-
before_action :application
|
8
|
-
|
9
7
|
def render_errors_for(model)
|
10
8
|
render json: model, status: :unprocessable_entity, serializer: ::Tramway::Api::V1::ErrorSerializer
|
11
9
|
end
|
@@ -91,6 +89,7 @@ module Tramway
|
|
91
89
|
end
|
92
90
|
|
93
91
|
def authenticate_user_if_needed
|
92
|
+
load_application
|
94
93
|
action_is_open = Tramway::Api.action_is_available(
|
95
94
|
action: action_name.to_sym,
|
96
95
|
project: (@application_engine || application_name),
|
@@ -112,17 +111,11 @@ module Tramway
|
|
112
111
|
protected
|
113
112
|
|
114
113
|
def application_name
|
115
|
-
|
114
|
+
@application ||= Tramway::Core.application&.model_class&.first || Tramway::Core.application
|
115
|
+
begin
|
116
116
|
@application.name
|
117
|
-
|
118
|
-
|
119
|
-
@application = Tramway::Core.application&.model_class&.first || Tramway::Core.application
|
120
|
-
end
|
121
|
-
if @application.present?
|
122
|
-
@application.name
|
123
|
-
else
|
124
|
-
raise("Tramway::Api @application not initialized, Tramway::Core.application: #{::Tramway::Core.application}, model_class: #{Tramway::Core.application&.model_class }")
|
125
|
-
end
|
117
|
+
rescue
|
118
|
+
raise("Tramway::Api @application not initialized, Tramway::Core.application: #{::Tramway::Core.application}, model_class: #{Tramway::Core.application&.model_class }")
|
126
119
|
end
|
127
120
|
end
|
128
121
|
|
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: 1.8.6.
|
4
|
+
version: 1.8.6.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|