pragma-decorator 2.2.6 → 2.3.0
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 +4 -4
- data/.rubocop.yml +3 -6
- data/CHANGELOG.md +8 -1
- data/README.md +8 -2
- data/lib/pragma/decorator/association.rb +1 -0
- data/lib/pragma/decorator/collection.rb +12 -6
- data/lib/pragma/decorator/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 67f54c6658ab7c26683372702f60dbf57d1b387b36e4f76906aa43564a895f3c
         | 
| 4 | 
            +
              data.tar.gz: 1e6dda3d51df96252a20f5be71fac7c97bfcafdcd6da3f9557dd114fc9ffd350
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 034e2d52748a517a49d795f62c5f7eef4853687ecf1129a7a252d568a85d64d888910f1233e113e05908d3600b0f30f405582669b9939ff57ee49001ffc2ee9a
         | 
| 7 | 
            +
              data.tar.gz: ce705e07d802802cb6517f70fc70d433812a014fdbdb587bc83b19b4ca67f3ebca1736c4a6d0e051cf8841dfb9138f7cb5d11aecbc43a0cb58e27abaf5c20fcd
         | 
    
        data/.rubocop.yml
    CHANGED
    
    | @@ -36,16 +36,16 @@ Metrics/LineLength: | |
| 36 36 | 
             
              Max: 100
         | 
| 37 37 | 
             
              AllowURI: true
         | 
| 38 38 |  | 
| 39 | 
            -
            Layout/ | 
| 39 | 
            +
            Layout/IndentFirstArgument:
         | 
| 40 40 | 
             
              Enabled: false
         | 
| 41 41 |  | 
| 42 42 | 
             
            Layout/MultilineMethodCallIndentation:
         | 
| 43 43 | 
             
              EnforcedStyle: indented
         | 
| 44 44 |  | 
| 45 | 
            -
            Layout/ | 
| 45 | 
            +
            Layout/IndentFirstArrayElement:
         | 
| 46 46 | 
             
              EnforcedStyle: consistent
         | 
| 47 47 |  | 
| 48 | 
            -
            Layout/ | 
| 48 | 
            +
            Layout/IndentFirstHashElement:
         | 
| 49 49 | 
             
              EnforcedStyle: consistent
         | 
| 50 50 |  | 
| 51 51 | 
             
            Style/SignalException:
         | 
| @@ -97,9 +97,6 @@ Capybara/FeatureMethods: | |
| 97 97 | 
             
            Metrics/ClassLength:
         | 
| 98 98 | 
             
              Enabled: false
         | 
| 99 99 |  | 
| 100 | 
            -
            Style/GuardClause:
         | 
| 101 | 
            -
              Enabled: false
         | 
| 102 | 
            -
             | 
| 103 100 | 
             
            Naming/FileName:
         | 
| 104 101 | 
             
              Exclude:
         | 
| 105 102 | 
             
                - 'pragma-decorator.gemspec'
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. | |
| 7 7 |  | 
| 8 8 | 
             
            ## [Unreleased]
         | 
| 9 9 |  | 
| 10 | 
            +
            ## [2.3.0]
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ### Added
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            - `Collection` now assumes the instance decorator is `Instance`
         | 
| 15 | 
            +
             | 
| 10 16 | 
             
            ## [2.2.6]
         | 
| 11 17 |  | 
| 12 18 | 
             
            ### Fixed
         | 
| @@ -93,7 +99,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. | |
| 93 99 |  | 
| 94 100 | 
             
            First Pragma 2 release.
         | 
| 95 101 |  | 
| 96 | 
            -
            [Unreleased]: https://github.com/pragmarb/pragma-decorator/compare/v2. | 
| 102 | 
            +
            [Unreleased]: https://github.com/pragmarb/pragma-decorator/compare/v2.3.0...HEAD
         | 
| 103 | 
            +
            [2.3.0]: https://github.com/pragmarb/pragma-decorator/compare/v2.2.6...v2.3.0
         | 
| 97 104 | 
             
            [2.2.6]: https://github.com/pragmarb/pragma-decorator/compare/v2.2.5...v2.2.6
         | 
| 98 105 | 
             
            [2.2.5]: https://github.com/pragmarb/pragma-decorator/compare/v2.2.4...v2.2.5
         | 
| 99 106 | 
             
            [2.2.4]: https://github.com/pragmarb/pragma-decorator/compare/v2.2.3...v2.2.4
         | 
    
        data/README.md
    CHANGED
    
    | @@ -118,7 +118,13 @@ module API | |
| 118 118 | 
             
            end
         | 
| 119 119 | 
             
            ```
         | 
| 120 120 |  | 
| 121 | 
            -
             | 
| 121 | 
            +
            `Array` and `ActiveRecord::Relation` are already overridden as `list` to avoid exposing internal
         | 
| 122 | 
            +
            details. If you want to specify your own global overrides, you can do it by adding entries to the
         | 
| 123 | 
            +
            `Pragma::Decorator::Type.overrides` hash:
         | 
| 124 | 
            +
             | 
| 125 | 
            +
            ```ruby
         | 
| 126 | 
            +
            Pragma::Decorator::Type.overrides['Article'] = 'post'
         | 
| 127 | 
            +
            ```
         | 
| 122 128 |  | 
| 123 129 | 
             
            ### Timestamps
         | 
| 124 130 |  | 
| @@ -244,7 +250,7 @@ module API | |
| 244 250 | 
             
                  module Decorator
         | 
| 245 251 | 
             
                    class Collection < Pragma::Decorator::Base
         | 
| 246 252 | 
             
                      include Pragma::Decorator::Collection
         | 
| 247 | 
            -
                      decorate_with Instance #  | 
| 253 | 
            +
                      decorate_with Instance # this is optional, the default is 'Instance'
         | 
| 248 254 |  | 
| 249 255 | 
             
                      property :total_cents, exec_context: :decorator
         | 
| 250 256 |  | 
| @@ -11,8 +11,6 @@ module Pragma | |
| 11 11 | 
             
                #   class ArticlesDecorator < Pragma::Decorator::Base
         | 
| 12 12 | 
             
                #     include Pragma::Decorator::Collection
         | 
| 13 13 | 
             
                #
         | 
| 14 | 
            -
                #     decorate_with ArticleDecorator
         | 
| 15 | 
            -
                #
         | 
| 16 14 | 
             
                #     property :total_count, exec_context: :decorator
         | 
| 17 15 | 
             
                #
         | 
| 18 16 | 
             
                #     def total_count
         | 
| @@ -60,10 +58,6 @@ module Pragma | |
| 60 58 | 
             
                  end
         | 
| 61 59 |  | 
| 62 60 | 
             
                  module ClassMethods # :nodoc:
         | 
| 63 | 
            -
                    # @!attribute [r]
         | 
| 64 | 
            -
                    #   @return [Class\Proc] the instance decorator to use
         | 
| 65 | 
            -
                    attr_reader :instance_decorator
         | 
| 66 | 
            -
             | 
| 67 61 | 
             
                    # Defines the decorator to use for each resource in the collection.
         | 
| 68 62 | 
             
                    #
         | 
| 69 63 | 
             
                    # @param decorator [Class|Proc] a decorator class, or a callable accepting a represented
         | 
| @@ -71,6 +65,18 @@ module Pragma | |
| 71 65 | 
             
                    def decorate_with(decorator)
         | 
| 72 66 | 
             
                      @instance_decorator = decorator
         | 
| 73 67 | 
             
                    end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                    # Returns the instance decorator for this collection.
         | 
| 70 | 
            +
                    #
         | 
| 71 | 
            +
                    # If no decorator was set manually with {#decorate_with}, this assumes the decorator is in
         | 
| 72 | 
            +
                    # the same namespace as the current class and is called +Instance+.
         | 
| 73 | 
            +
                    #
         | 
| 74 | 
            +
                    # @return [Class\Proc] the instance decorator to use
         | 
| 75 | 
            +
                    def instance_decorator
         | 
| 76 | 
            +
                      @instance_decorator ||= Object.const_get((
         | 
| 77 | 
            +
                        name.split('::')[0..-2] + ['Instance']
         | 
| 78 | 
            +
                      ).join('::'))
         | 
| 79 | 
            +
                    end
         | 
| 74 80 | 
             
                  end
         | 
| 75 81 | 
             
                end
         | 
| 76 82 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pragma-decorator
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Alessandro Desantis
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2019-06-23 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: roar
         |