ii_interactor 2.3.0 → 2.3.1
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/CHANGELOG.md +4 -0
- data/README.md +15 -10
- data/lib/ii_interactor/contextualizer.rb +4 -0
- data/lib/ii_interactor/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: d84fbe8e54e1c6e2ae2db5e42a0fa69e6242e625ff959544e47b6f51487c5197
         | 
| 4 | 
            +
              data.tar.gz: 1abd9bcdc2f2f54286f09216ff4a65df6b932a404bfdfd2cfeb6365167e8d3c3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7dacc28bf13a431d29cb1033c5b22564033be5411faf9db9735797daacb3f643ffab744b95e596fe5830cd8bb20838d2935e891bd9e2edfbb2610cdd65ef700c
         | 
| 7 | 
            +
              data.tar.gz: b5fa3f044ec335297efc753236f4a2e4d8e8e29d394cdace78f8ad7d29a4e9fd85152a83e87520da759f55f48449fe4416bd8bc228a852d80947f46f13606130
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -27,8 +27,8 @@ Create interactor with `call` method and call it as follows: | |
| 27 27 |  | 
| 28 28 | 
             
            ```ruby
         | 
| 29 29 | 
             
            class Interactor < IIInteractor::Base
         | 
| 30 | 
            -
               | 
| 31 | 
            -
               | 
| 30 | 
            +
              context :message
         | 
| 31 | 
            +
              context :result
         | 
| 32 32 |  | 
| 33 33 | 
             
              def call
         | 
| 34 34 | 
             
                @context.result = "called by #{@context.message}"
         | 
| @@ -36,15 +36,14 @@ class Interactor < IIInteractor::Base | |
| 36 36 | 
             
            end
         | 
| 37 37 |  | 
| 38 38 | 
             
            Interactor.call(message: 'something')
         | 
| 39 | 
            -
            #=> #<IIInteractor::Context message | 
| 39 | 
            +
            #=> #<IIInteractor::Context @_data={:message=>"something", :result=>"called by something"}>
         | 
| 40 40 | 
             
            ```
         | 
| 41 41 |  | 
| 42 42 | 
             
            The first argument of `Interactor.call` is set to `@context`.
         | 
| 43 43 | 
             
            The return value of `Interactor.call` is the same as `@context`.
         | 
| 44 44 |  | 
| 45 | 
            -
            You can define context variables used in interactor explicitly.
         | 
| 46 | 
            -
            ` | 
| 47 | 
            -
            while `context_out` copies instance variables of interactor to context.
         | 
| 45 | 
            +
            You can define context variables used in interactor explicitly by using the `context` method.
         | 
| 46 | 
            +
            `context` method copies the input variables to instance variables of the interactor.
         | 
| 48 47 |  | 
| 49 48 | 
             
            ### Context options
         | 
| 50 49 |  | 
| @@ -52,18 +51,18 @@ You can define required context as follows: | |
| 52 51 |  | 
| 53 52 | 
             
            ```ruby
         | 
| 54 53 | 
             
            class Interactor < IIInteractor::Base
         | 
| 55 | 
            -
               | 
| 54 | 
            +
              context :input, required: true
         | 
| 56 55 | 
             
            end
         | 
| 57 56 |  | 
| 58 57 | 
             
            Interactor.call
         | 
| 59 | 
            -
            #=>  | 
| 58 | 
            +
            #=> missing required context: input (Coactive::MissingContextError)
         | 
| 60 59 | 
             
            ```
         | 
| 61 60 |  | 
| 62 61 | 
             
            You can also define default value as follows:
         | 
| 63 62 |  | 
| 64 63 | 
             
            ```ruby
         | 
| 65 64 | 
             
            class Interactor < IIInteractor::Base
         | 
| 66 | 
            -
               | 
| 65 | 
            +
              context :input, default: 'input'
         | 
| 67 66 |  | 
| 68 67 | 
             
              def call
         | 
| 69 68 | 
             
                puts @input
         | 
| @@ -78,7 +77,7 @@ You can also set context from return value of `call` method: | |
| 78 77 |  | 
| 79 78 | 
             
            ```ruby
         | 
| 80 79 | 
             
            class Interactor < IIInteractor::Base
         | 
| 81 | 
            -
               | 
| 80 | 
            +
              context :result, output: :return
         | 
| 82 81 |  | 
| 83 82 | 
             
              def call
         | 
| 84 83 | 
             
                'returned value'
         | 
| @@ -139,6 +138,8 @@ end | |
| 139 138 | 
             
            class MainInteractor < IIInteractor::Base
         | 
| 140 139 | 
             
              coact AInteractor
         | 
| 141 140 | 
             
              coact BInteractor
         | 
| 141 | 
            +
             | 
| 142 | 
            +
              context :message
         | 
| 142 143 | 
             
            end
         | 
| 143 144 |  | 
| 144 145 | 
             
            context = MainInteractor.call
         | 
| @@ -182,6 +183,8 @@ end | |
| 182 183 | 
             
            class MainInteractor < IIInteractor::Base
         | 
| 183 184 | 
             
              coact AInteractor
         | 
| 184 185 | 
             
              coact BInteractor
         | 
| 186 | 
            +
             | 
| 187 | 
            +
              context :message
         | 
| 185 188 | 
             
            end
         | 
| 186 189 |  | 
| 187 190 | 
             
            context = MainInteractor.call
         | 
| @@ -208,6 +211,8 @@ For example: | |
| 208 211 |  | 
| 209 212 | 
             
            ```ruby
         | 
| 210 213 | 
             
            class Interactor < IIInteractor::Base
         | 
| 214 | 
            +
              context :message
         | 
| 215 | 
            +
             | 
| 211 216 | 
             
              before_all do
         | 
| 212 217 | 
             
                puts "before_all"
         | 
| 213 218 | 
             
              end
         | 
| @@ -13,6 +13,7 @@ module IIInteractor | |
| 13 13 |  | 
| 14 14 | 
             
                class_methods do
         | 
| 15 15 | 
             
                  def context_in(*names, **options)
         | 
| 16 | 
            +
                    warn "DEPRECATION WARNING: 'context_in' is deprecated. Use 'context :x' instead. (#{caller[0]})"
         | 
| 16 17 | 
             
                    context(*names, **options)
         | 
| 17 18 | 
             
                  end
         | 
| 18 19 |  | 
| @@ -20,6 +21,9 @@ module IIInteractor | |
| 20 21 | 
             
                    options[:output] = true
         | 
| 21 22 | 
             
                    if options.delete(:from_return)
         | 
| 22 23 | 
             
                      options[:output] = :return
         | 
| 24 | 
            +
                      warn "DEPRECATION WARNING: 'context_out' is deprecated. Use 'context :x, output: :return' instead. (#{caller[0]})"
         | 
| 25 | 
            +
                    else
         | 
| 26 | 
            +
                      warn "DEPRECATION WARNING: 'context_out' is deprecated. Use 'context :x, output: true' instead. (#{caller[0]})"
         | 
| 23 27 | 
             
                    end
         | 
| 24 28 | 
             
                    context(*names, **options)
         | 
| 25 29 | 
             
                  end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ii_interactor
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.3. | 
| 4 | 
            +
              version: 2.3.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Yoshikazu Kaneta
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-07-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         |