rom-core 4.0.0.rc1 → 4.0.0.rc2

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
  SHA1:
3
- metadata.gz: dd842da91b8eff4e935f9bc0064b7225fbc41d6a
4
- data.tar.gz: b949c0798bbddfb9bb49b52b0e4137759accc1f7
3
+ metadata.gz: bbc8460e253bf0a3520abb95d611577ec40b4974
4
+ data.tar.gz: 3dbda2f926ccd90f50ef326798ed0420cafe2b0f
5
5
  SHA512:
6
- metadata.gz: c95c856d8c205db0013f905ad72e4e8bcecc243f227410d05607c8e2f1280e5d7cf8943c607cd6b45f5926e55e8febadab4e809cb847efe3e96c48e8c4873200
7
- data.tar.gz: bf2277dae18e48950740d93a6478cf4d0d56eda97065b797edb5d88d8ab9327f871ab99d2207a909ae80663ae0a654b2495485be7ddf071ab5da6105737b9db8
6
+ metadata.gz: d081489a27d141a741efc64e8119e92247e7d9bc196f24b18e150182b395d893e90804a90c275930065aba2d34b26ae91121b9413752d75eb6d2b541b586325a
7
+ data.tar.gz: 42b21a86b93e53f190f1aa439336b15c9ea1e4454c35ec37a19e6313ddec2e26d9f0b98f5b4f3b6a47266aa9fa0bafdb559a94c031f70e98ed8c3a3592b9a7ad
@@ -23,7 +23,7 @@ Previous `rom` gem was renamed to `rom-core`
23
23
 
24
24
  ## Changed
25
25
 
26
- * Works with MRI >= 2.2
26
+ * Works with MRI >= 2.3
27
27
  * [BREAKING] Inferring relations from database schema **has been removed**. You need to define relations explicitly now (solnic)
28
28
  * [BREAKING] Relations have `auto_map` **turned on by default**. This means that wraps and graphs return nested data structures automatically (solnic)
29
29
  * [BREAKING] `Relation#combine` behavior from previous versions is now provided by `Relation#combine_with` (solnic)
@@ -77,7 +77,7 @@ module ROM
77
77
  #
78
78
  # @param [Symbol] name The node relation name
79
79
  #
80
- # @yieldparam [Relation] The relation node
80
+ # @yieldparam [Relation] relation The relation node
81
81
  # @yieldreturn [Relation] The new relation node
82
82
  #
83
83
  # @return [Relation]
@@ -107,6 +107,26 @@ module ROM
107
107
  with_nodes(new_nodes)
108
108
  end
109
109
 
110
+ # Return a `:create` command that can insert data from a nested hash.
111
+ #
112
+ # This is limited to `:create` commands only, because automatic restriction
113
+ # for `:update` commands would be quite complex. It's possible that in the
114
+ # future support for `:update` commands will be added though.
115
+ #
116
+ # Another limitation is that it can only work when you're composing
117
+ # parent and its child(ren), which follows canonical hierarchy from your
118
+ # database, so that parents are created first, then their PKs are set
119
+ # as FKs in child tuples. It should be possible to make it work with
120
+ # both directions (parent => child or child => parent), and it would
121
+ # require converting input tuples based on how they depend on each other,
122
+ # which we could do in the future.
123
+ #
124
+ # Expanding functionality of this method is planned for rom 5.0.
125
+ #
126
+ # @see Relation#command
127
+ #
128
+ # @raise NotImplementedError when type is not `:create`
129
+ #
110
130
  # @api public
111
131
  def command(type, *args)
112
132
  if type == :create
@@ -6,20 +6,37 @@ module ROM
6
6
  module Commands
7
7
  # Return a command for the relation
8
8
  #
9
- # @example
9
+ # This method can either return an existing custom command identified
10
+ # by `type` param, or generate a command dynamically based on relation
11
+ # AST.
12
+ #
13
+ # @example build a simple :create command
10
14
  # users.command(:create)
11
15
  #
16
+ # @example build a command which returns multiple results
17
+ # users.command(:create, result: many)
18
+ #
19
+ # @example build a command which uses a specific plugin
20
+ # users.command(:create, plugin: :timestamps)
21
+ #
22
+ # @example build a command which sends results through a custom mapper
23
+ # users.command(:create, mapper: :my_mapper_identifier)
24
+ #
25
+ # @example return an existing custom command
26
+ # users.command(:my_custom_command_identifier)
27
+ #
12
28
  # @param type [Symbol] The command type (:create, :update or :delete)
13
- # @option :mapper [ROM::Mapper] An optional mapper applied to the command result
14
- # @option :use [Array<Symbol>] A list of command plugins
15
- # @option :result [:one, :many] Whether the command result has one or more rows.
16
- # :one is default
29
+ # @param opts [Hash] Additional options
30
+ # @option opts [Symbol] :mapper (nil) An optional mapper applied to the command result
31
+ # @option opts [Array<Symbol>] :use ([]) A list of command plugins
32
+ # @option opts [Symbol] :result (:one) Set how many results the command should return.
33
+ # Can be `:one` or `:many`
17
34
  #
18
35
  # @return [ROM::Command]
19
36
  #
20
37
  # @api public
21
38
  def command(type, mapper: nil, use: EMPTY_ARRAY, **opts)
22
- base_command = commands[type, adapter, to_ast, use, opts]
39
+ base_command = commands.key?(type) ? commands[type] : commands[type, adapter, to_ast, use, opts]
23
40
 
24
41
  command =
25
42
  if mapper
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module Core
3
- VERSION = '4.0.0.rc1'.freeze
3
+ VERSION = '4.0.0.rc2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc1
4
+ version: 4.0.0.rc2
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-09-15 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -59,6 +59,9 @@ dependencies:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.12'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 0.12.1
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
@@ -66,6 +69,9 @@ dependencies:
66
69
  - - "~>"
67
70
  - !ruby/object:Gem::Version
68
71
  version: '0.12'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.12.1
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: dry-core
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +106,14 @@ dependencies:
100
106
  requirements:
101
107
  - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: 1.0.0.beta
109
+ version: 1.0.0.rc
104
110
  type: :runtime
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
114
  - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: 1.0.0.beta
116
+ version: 1.0.0.rc
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: rake
113
119
  requirement: !ruby/object:Gem::Requirement