tramway-api 1.8.4 → 1.8.6.3
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
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e7f1b8dfe3e44248a5689bd7a38f15457cfdb51a5e86c57ced95eff20b177310
         | 
| 4 | 
            +
              data.tar.gz: 6fd69e46c891249e0f9177b596b17242f209c4d2fc38eab9419dd208b64b1de2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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 | 
            -
                       | 
| 28 | 
            -
             | 
| 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. | 
| 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. | 
| 9 | 
            +
                id_method = Tramway::Api.default_id_method_of(model: object.class) || :uuid
         | 
| 10 10 | 
             
                object.send(id_method)
         | 
| 11 11 | 
             
              end
         | 
| 12 12 |  | 
    
        data/lib/tramway/api.rb
    CHANGED
    
    | @@ -91,8 +91,12 @@ module Tramway | |
| 91 91 | 
             
                    end)
         | 
| 92 92 | 
             
                  end
         | 
| 93 93 |  | 
| 94 | 
            -
                  def  | 
| 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
         | 
    
        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. | 
| 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- | 
| 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
         |