hanami-model 1.1.0 → 1.2.0.beta1

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
- SHA1:
3
- metadata.gz: baa67e9dd75be68366898314a21f009c72516403
4
- data.tar.gz: 25c3f3892d14131966a71dbe18a9339b5b3c1b69
2
+ SHA256:
3
+ metadata.gz: 6ee9520de27f9ac65d7d42d6ea89e0a923d254d96fd43efca0ce91e355117613
4
+ data.tar.gz: 0a81d29d744e7757da64ab862301558292967be1b7dc5bfcd6a1e698a344df89
5
5
  SHA512:
6
- metadata.gz: 9244838d4936d70bd1a24d4e8cce9944b91527d96999dee94eb0d5a2bf8d39b62350197cd4ff8f0bd0d10e154687850401b2c92aa89ae54d1a506aa6d069a8f3
7
- data.tar.gz: 80b5cef9d91ea29db8312eae0a7659b03333cf49a34a35d0b5e08086af020f1ea0a49f29aa8517aac5716c252edea6ad35f1ad23b0dd1fec0c0e5b1a3945234d
6
+ metadata.gz: a739e769973add9508c16fac6e10078bd5adf1d4ef19cf83ebf4b5ffab7df5cc22c9a5f80f19430351a57b1209fd43760317c91b127550544e31ceb1f2bcf91b
7
+ data.tar.gz: 0bc442febb0e18f2472760fbf8637743b3efd1e6f513b026f4812fc7db73e7f18bed6421d397c7d75a96e30fac28cf484b2970b2dd75e1029815272cb19c7a29
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Hanami::Model
2
2
  A persistence layer for Hanami
3
3
 
4
+ ## v1.2.0.beta1 - 2018-02-28
5
+ ### Added
6
+ - [Luca Guidi] Official support for Ruby: MRI 2.5
7
+ - [Marcello Rocha] Introduce `Hanami::Repository#command` as a factory for custom database commands. This is useful to create custom bulk operations.
8
+
4
9
  ## v1.1.0 - 2017-10-25
5
10
  ### Fixed
6
11
  - [Luca Guidi] Ensure associations to always accept objects that are serializable into `::Hash`
data/hanami-model.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
  spec.required_ruby_version = '>= 2.3.0'
20
20
 
21
- spec.add_runtime_dependency 'hanami-utils', '~> 1.1'
21
+ spec.add_runtime_dependency 'hanami-utils', '1.2.0.beta1'
22
22
  spec.add_runtime_dependency 'rom', '~> 3.3', '>= 3.3.3'
23
23
  spec.add_runtime_dependency 'rom-sql', '~> 1.3', '>= 1.3.5'
24
24
  spec.add_runtime_dependency 'rom-repository', '~> 1.4'
@@ -49,7 +49,7 @@ module Hanami
49
49
  # @since 0.7.0
50
50
  # @api private
51
51
  def create(data)
52
- entity.new(command(:create, aggregate(target), use: [:timestamps])
52
+ entity.new(command(:create, aggregate(target), mapper: nil, use: [:timestamps])
53
53
  .call(serialize(data)))
54
54
  rescue => e
55
55
  raise Hanami::Model::Error.for(e)
@@ -113,7 +113,7 @@ module Hanami
113
113
  # @since 0.7.0
114
114
  # @api private
115
115
  def command(target, relation, options = {})
116
- repository.command(target, relation, options)
116
+ repository.command(target => relation, **options)
117
117
  end
118
118
 
119
119
  # @since 0.7.0
@@ -51,20 +51,20 @@ module Hanami
51
51
 
52
52
  def create(data)
53
53
  entity.new(
54
- command(:create, aggregate(target), use: [:timestamps]).call(serialize(data))
54
+ command(:create, aggregate(target), mapper: nil).call(serialize(data))
55
55
  )
56
56
  rescue => e
57
57
  raise Hanami::Model::Error.for(e)
58
58
  end
59
59
 
60
60
  def add(data)
61
- command(:create, relation(target), use: [:timestamps]).call(associate(serialize(data)))
61
+ command(:create, relation(target), mapper: nil).call(associate(serialize(data)))
62
62
  rescue => e
63
63
  raise Hanami::Model::Error.for(e)
64
64
  end
65
65
 
66
66
  def update(data)
67
- command(:update, relation(target), use: [:timestamps])
67
+ command(:update, relation(target), mapper: nil)
68
68
  .by_pk(
69
69
  one.public_send(relation(target).primary_key)
70
70
  ).call(serialize(data))
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.1.0'.freeze
6
+ VERSION = '1.2.0.beta1'.freeze
7
7
  end
8
8
  end
@@ -132,6 +132,33 @@ module Hanami
132
132
  Hanami::Model.container
133
133
  end
134
134
 
135
+ # Define a new ROM::Command while preserving the defaults used by Hanami itself.
136
+ #
137
+ # It allows the user to define a new command to, for example,
138
+ # create many records at the same time and still get entities back.
139
+ #
140
+ # The first argument is the command and relation it will operate on.
141
+ #
142
+ # @return [ROM::Command] the created command
143
+ #
144
+ # @example
145
+ # # In this example, calling the create_many method with and array of data,
146
+ # # would result in the creation of records and return an Array of Task entities.
147
+ #
148
+ # class TaskRepository < Hanami::Repository
149
+ # def create_many(data)
150
+ # command(create: :tasks, result: :many).call(data)
151
+ # end
152
+ # end
153
+ #
154
+ # @since 1.2.0
155
+ def command(*args, **opts, &block)
156
+ opts[:use] = COMMAND_PLUGINS | Array(opts[:use])
157
+ opts[:mapper] = opts.fetch(:mapper, Model::MappedRelation.mapper_name)
158
+
159
+ super(*args, **opts, &block)
160
+ end
161
+
135
162
  # Define a database relation, which describes how data is fetched from the
136
163
  # database.
137
164
  #
@@ -162,7 +189,7 @@ module Hanami
162
189
  def #{relation}
163
190
  Hanami::Model::MappedRelation.new(@#{relation})
164
191
  end
165
- }
192
+ }, __FILE__, __LINE__ - 4
166
193
  end
167
194
  # rubocop:enable Metrics/AbcSize
168
195
  # rubocop:enable Metrics/MethodLength
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-25 00:00:00.000000000 Z
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: 1.2.0.beta1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.1'
26
+ version: 1.2.0.beta1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rom
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -215,12 +215,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
215
  version: 2.3.0
216
216
  required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  requirements:
218
- - - ">="
218
+ - - ">"
219
219
  - !ruby/object:Gem::Version
220
- version: '0'
220
+ version: 1.3.1
221
221
  requirements: []
222
222
  rubyforge_project:
223
- rubygems_version: 2.6.13
223
+ rubygems_version: 2.7.5
224
224
  signing_key:
225
225
  specification_version: 4
226
226
  summary: A persistence layer for Hanami