tramway-api 1.8.4 → 1.8.6.3

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: 1c007eb42b91d7a7b138884b5ce40739a7f90b63254c223c6a82a16b652e9e47
4
- data.tar.gz: 5634bf604e6984e540fdfa1bcab1b4a93aca5e0a3e140756711b6e1f3c993f25
3
+ metadata.gz: e7f1b8dfe3e44248a5689bd7a38f15457cfdb51a5e86c57ced95eff20b177310
4
+ data.tar.gz: 6fd69e46c891249e0f9177b596b17242f209c4d2fc38eab9419dd208b64b1de2
5
5
  SHA512:
6
- metadata.gz: 9af7275766df2240504ae8c258ccc0f0e278855890ccf2fdb03ab735f90aa9252dd2ab462f1adb8e8ede509b3ec0e508b1c2db746932e34196c2fdc67253639c
7
- data.tar.gz: ebe525f69af40b34e0f8f12bf70205dcc7d1072462eda9ffadf04858137faeec96b42556e71e30f66724011245f595021deb3a5240a223e734012a5da8e6feb0
6
+ metadata.gz: 0addb5574a3f3dd5308d94c2a7e023c41d864bf909119e34d258b0339245f94155105ea9605b406e32f9edb85ce2c9e15d0e30f7dfca2f6a401378a4314c020d
7
+ data.tar.gz: 23d22cdb67d958d36c39a80c1794b202eae925931553f4910637074024bb601429d516d0f498911be45d605454cf5879039ef72ddfbf8432ba57e5cdf6aa1a77
@@ -24,14 +24,21 @@ module Tramway
24
24
  private
25
25
 
26
26
  def record
27
- id_method = Tramway::Api.id_method_of(model: model_class) || :uuid
28
- @record = model_class.find_by! id_method => params[:id] if params[:id].present?
27
+ if params[:key].present?
28
+ if Tramway::Api.other_id_methods_of(model: model_class).include? params[:key]
29
+ @record = model_class.find_by! params[:key] => params[:id] if params[:id].present?
30
+ end
31
+ else
32
+ default_id_method = Tramway::Api.default_id_method_of(model: model_class) || :uuid
33
+ @record = model_class.find_by! default_id_method => params[:id] if params[:id].present?
34
+ end
29
35
  end
30
36
 
31
37
  def records
32
38
  active_records = model_class.respond_to?(:active) ? model_class.active : model_class.all
33
39
  collection = active_records.order(id: :desc).send params[:scope] || :all
34
- collection = collection.full_text_search params[:search] if params[:search]
40
+ collection = collection.page(params[:page]).per(params[:per]) if params[:page].present?
41
+ collection = collection.full_text_search params[:search] if params[:search].present?
35
42
  collection
36
43
  end
37
44
 
@@ -6,7 +6,7 @@ class Tramway::Api::V1::ApplicationSerializer < ActiveModel::Serializer
6
6
  attribute :id
7
7
 
8
8
  def id
9
- id_method = Tramway::Api.id_method_of(model: object.class) || :uuid
9
+ id_method = Tramway::Api.default_id_method_of(model: object.class) || :uuid
10
10
  object.send(id_method)
11
11
  end
12
12
 
@@ -91,8 +91,12 @@ module Tramway
91
91
  end)
92
92
  end
93
93
 
94
- def id_method_of(model:)
95
- @@id_methods[model.to_s]
94
+ def other_id_methods_of(model:)
95
+ @@id_methods[model.to_s][:other]
96
+ end
97
+
98
+ def default_id_method_of(model:)
99
+ @@id_methods[model.to_s][:default]
96
100
  end
97
101
  end
98
102
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Api
5
- VERSION = '1.8.4'
5
+ VERSION = '1.8.6.3'
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.4
4
+ version: 1.8.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-23 00:00:00.000000000 Z
11
+ date: 2020-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers