tramway-api 1.8.6.10 → 1.8.7

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: eac6742207080fc85dd8b83884206f932e8b92dd9ac29a9ee748274bff7f823a
4
- data.tar.gz: 3fc429d2b9e90a4cd4b1349aa03541057e60147f59a8312cd1bb39e390cd62b3
3
+ metadata.gz: 7460f1d97abb9ea3e24e8cf6b5e3bb81fece303364dd906f4a42617ae92ed08b
4
+ data.tar.gz: 772e32b2c3c73a501b49fb2a166d99256558e221f71254d47094d6ec2d8d9b10
5
5
  SHA512:
6
- metadata.gz: 8fc3526803e3cc00c3eebcc1728042e9dde54fa6f1c9b8e9df8a21960544afaac4b0a2f9b899b85380977fafa0c28670eac9a9c21fc15c162207c77d5dccd1b3
7
- data.tar.gz: cba7da12631b2f8010348dc1f460ff1bfaccdcb4586badb78163b21ea55be708337ce596133c65a59c35c70f8d45c4cf4948beb3f015e06f75ade4b81bc68ca4
6
+ metadata.gz: d706c1f376c0300a3c8ae6b2a7af4e3ec987b67960301d6aa52a5d69d4475c6e2910d854d91671a5584aebeffed2f3560780d55cd7afc6fb3a13c05041c42987
7
+ data.tar.gz: c3e35375b7597d57cc2d96cb6cc37cfd1084327afb23a1931d9a19ca93314b60f8d5f24335f7747f7fdf388860c28213c7c5895c914bddd1b72b748da853278b
@@ -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),
@@ -8,9 +8,11 @@ module Tramway::Api::V1
8
8
  before_action :application
9
9
 
10
10
  def index
11
- collection = available_action_for_collection
11
+ @collection = available_action_for_collection
12
12
 
13
- render json: collection,
13
+ raise 'Collection has empty uuid. It should not be empty, because all records with empty uuid will not be rendered' if @collection.map(&:uuid).map(&:empty?).include? true
14
+
15
+ render json: @collection,
14
16
  each_serializer: serializer_class,
15
17
  include: '*',
16
18
  status: :ok
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Api
5
- VERSION = '1.8.6.10'
5
+ VERSION = '1.8.7'
6
6
  end
7
7
  end
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.10
4
+ version: 1.8.7
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-06 00:00:00.000000000 Z
11
+ date: 2021-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.5
19
+ version: 0.10.12
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.5
26
+ version: 0.10.12
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: knock
29
29
  requirement: !ruby/object:Gem::Requirement