rom-repository 1.0.0.beta1 → 1.0.0.beta2
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 +1 -0
- data/lib/rom/repository/command_compiler.rb +1 -1
- data/lib/rom/repository/relation_proxy.rb +2 -2
- data/lib/rom/repository/relation_proxy/combine.rb +1 -1
- data/lib/rom/repository/relation_proxy/wrap.rb +2 -1
- data/lib/rom/repository/struct_builder.rb +1 -3
- data/lib/rom/repository/version.rb +1 -1
- data/spec/integration/command_spec.rb +2 -2
- data/spec/integration/repository_spec.rb +11 -0
- data/spec/shared/repo.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: cdb0dfc90b48097d286f0d5b79790560d79c8fdd
         | 
| 4 | 
            +
              data.tar.gz: ed15356517cc1dff17729d851e53b77f75727075
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: cc5b70717bbfb200cad2dc539f89c438398ae3dd3c6fb3f10f8d1c58c48e2be2b5d7bc01a729f738400e9b5021dbb070aa14fbdaec98c5ec8f30b57511e6448c
         | 
| 7 | 
            +
              data.tar.gz: 88d6e30ab3107d583119ab1ed2a48bb83e138b2bc5026235acbb1a6932302a34037bb5315de976479d0c58895cb841026fe3239f8c3326e2093d882faf84942e
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -11,6 +11,7 @@ | |
| 11 11 | 
             
            * Ability to define custom changeset classes that can be instantiated via `repo.changeset(MyChangesetClass[:rel_name]).data(some_data)` where `MyChangesetClass` inherits from a core changeset class (solnic)
         | 
| 12 12 | 
             
            * `Changeset.map` which accepts a block and exposes a DSL for data transformations (all [transproc hash methods](https://github.com/solnic/transproc)) are available (solnic)
         | 
| 13 13 | 
             
            * `Changeset#associate` method that accepts another changeset or parent data and an association identifier, ie `post_changeset.associate(user, :author)` (solnic)
         | 
| 14 | 
            +
            * You can now use `wrap_parent` in combined relations too (which is gazillion times faster than `combine_parents`) (solnic)
         | 
| 14 15 |  | 
| 15 16 | 
             
            ### Changed
         | 
| 16 17 |  | 
| @@ -84,7 +84,7 @@ module ROM | |
| 84 84 | 
             
                  #
         | 
| 85 85 | 
             
                  # @api private
         | 
| 86 86 | 
             
                  def with(new_options)
         | 
| 87 | 
            -
                    __new__(relation, new_options)
         | 
| 87 | 
            +
                    __new__(relation, options.merge(new_options))
         | 
| 88 88 | 
             
                  end
         | 
| 89 89 |  | 
| 90 90 | 
             
                  # Returns if this relation is combined aka a relation graph
         | 
| @@ -189,7 +189,7 @@ module ROM | |
| 189 189 | 
             
                  #
         | 
| 190 190 | 
             
                  # @api private
         | 
| 191 191 | 
             
                  def wraps
         | 
| 192 | 
            -
                    meta.fetch(:wraps,  | 
| 192 | 
            +
                    meta.fetch(:wraps, EMPTY_ARRAY)
         | 
| 193 193 | 
             
                  end
         | 
| 194 194 |  | 
| 195 195 | 
             
                  # Forward to relation and wrap it with proxy if response was a relation too
         | 
| @@ -38,7 +38,8 @@ module ROM | |
| 38 38 | 
             
                    def wrap_parent(options)
         | 
| 39 39 | 
             
                      wrap(
         | 
| 40 40 | 
             
                        options.each_with_object({}) { |(name, parent), h|
         | 
| 41 | 
            -
                           | 
| 41 | 
            +
                          keys = combine_keys(parent, relation, :children)
         | 
| 42 | 
            +
                          h[name] = [parent, keys]
         | 
| 42 43 | 
             
                        }
         | 
| 43 44 | 
             
                      )
         | 
| 44 45 | 
             
                    end
         | 
| @@ -50,9 +50,7 @@ module ROM | |
| 50 50 | 
             
                  end
         | 
| 51 51 |  | 
| 52 52 | 
             
                  def visit_attribute(attr)
         | 
| 53 | 
            -
                     | 
| 54 | 
            -
                      [attr.aliased? && !attr.wrapped? ? attr.alias : attr.name, attr.type]
         | 
| 55 | 
            -
                    end
         | 
| 53 | 
            +
                    [attr.aliased? && !attr.wrapped? ? attr.alias : attr.name, attr.type]
         | 
| 56 54 | 
             
                  end
         | 
| 57 55 |  | 
| 58 56 | 
             
                  def build_class(name, parent, &block)
         | 
| @@ -37,9 +37,9 @@ RSpec.describe ROM::Repository, '#command' do | |
| 37 37 | 
             
                  expect(user.name).to eql('Jane Doe')
         | 
| 38 38 | 
             
                end
         | 
| 39 39 |  | 
| 40 | 
            -
                it 'uses  | 
| 40 | 
            +
                it 'uses input_schema for command input' do
         | 
| 41 41 | 
             
                  create_user = repo.command(create: :users)
         | 
| 42 | 
            -
                  expect(create_user.input).to eql(repo.users. | 
| 42 | 
            +
                  expect(create_user.input).to eql(repo.users.input_schema)
         | 
| 43 43 | 
             
                end
         | 
| 44 44 |  | 
| 45 45 | 
             
                it 'caches commands' do
         | 
| @@ -95,6 +95,17 @@ RSpec.describe 'ROM repository' do | |
| 95 95 | 
             
                expect(jane.labels[1].name).to eql('blue')
         | 
| 96 96 | 
             
              end
         | 
| 97 97 |  | 
| 98 | 
            +
              it 'loads children and its parents via wrap' do
         | 
| 99 | 
            +
                posts = repo.posts.wrap_parent(author: repo.users)
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                label = repo.labels.combine(many: { posts: posts }).first
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                expect(label.name).to eql('red')
         | 
| 104 | 
            +
                expect(label.posts.size).to be(1)
         | 
| 105 | 
            +
                expect(label.posts[0].title).to eql('Hello From Jane')
         | 
| 106 | 
            +
                expect(label.posts[0].author.name).to eql('Jane')
         | 
| 107 | 
            +
              end
         | 
| 108 | 
            +
             | 
| 98 109 | 
             
              it 'loads a parent via custom fks' do
         | 
| 99 110 | 
             
                post = repo.posts.combine(:author).where(title: 'Hello From Jane').one
         | 
| 100 111 |  | 
    
        data/spec/shared/repo.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rom-repository
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0.0. | 
| 4 | 
            +
              version: 1.0.0.beta2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Piotr Solnica
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017-01- | 
| 11 | 
            +
            date: 2017-01-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rom
         |