on_form 2.1.0 → 2.2.0

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: febeec1d904aefce31f0499e1a0259caff00003c
4
- data.tar.gz: 0fa55ca7d0f8692479ae9ee574a1e2f03f2ed42c
3
+ metadata.gz: ef390c085a64b23daf7e8439918a5db0c33d351f
4
+ data.tar.gz: fb98c2b228bfb52f2a732a09d513afa7643f840e
5
5
  SHA512:
6
- metadata.gz: c3a32337ff68ecc0037ab9fb431b279f6897fda0f2a82c90a657add23ca0eeac43c1ce1bf517e2768fa2caa471399551fa32b5a25cc4478912632011ea679dcc
7
- data.tar.gz: bb78f1d4a027fee037958b23e232c9c381efa7c9d426018e9b6723e7060a1042c2d14b0876302c75e555226c236e795a2bc49dac33709f45136b78b12dc0b90a
6
+ metadata.gz: fb5bf8f542ea1243dfe9f232e7cf8fe603b8ab908142d1a657c2c99bd38c41c8c125486a356815881192f6c776f5705e90ee12a9e5d56e4034da710906c3f8d4
7
+ data.tar.gz: 6dcf2fa5591a255808602edba8399b0625d36c63d6fd9cd65e8c8e0dce24fda3b51c2e1ec5f134501a94e11451c587cc3ed45f8b8e4a9ee344784e635d9d947d
data/CHANGES.md CHANGED
@@ -1,15 +1,23 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- 2.01
5
- ----
4
+ 2.2.0
5
+ -----
6
+ * Remove the previously existing transaction caveat around model-less saves.
7
+
8
+ 2.1.0
9
+ -----
10
+ * Implement support for introducing typed "artificial" attributes.
11
+
12
+ 2.0.1
13
+ -----
6
14
  * Fix regressions in support for Rails 4.2.
7
15
  * Support some additional attribute methods such as `*_was` and `*_changed?`.
8
16
 
9
- 2.00
10
- ----
17
+ 2.0.0
18
+ -----
11
19
  * New expose syntax to support prefix:, suffix:, and as: options.
12
20
 
13
- 1.00
14
- ----
21
+ 1.0.0
22
+ -----
15
23
  * First public release.
data/README.md CHANGED
@@ -228,7 +228,7 @@ end
228
228
 
229
229
  ### Model-less forms
230
230
 
231
- Taking this one step further, you can define forms which have _no_ exposed model attributes. *Be aware that forms that expose no models do not automatically start a database transaction, because they don't know which database connection to use.*
231
+ Taking this one step further, you can define forms which have _no_ exposed model attributes.
232
232
 
233
233
  To actually perform a data change in response to the form submission, you can add a `before_save` or `after_save` callback and from there call your existing model code or service objects. It's best to keep the code in the form object to just the bits specific to the form - try not to put your business logic in your form objects!
234
234
 
@@ -264,6 +264,8 @@ class ChangePasswordForm < OnForm::Form
264
264
  end
265
265
  ```
266
266
 
267
+ Note that when you have no exposed models, OnForm will still wrap the save process in a database transaction for you, using `ActiveRecord::Base.transaction`. If you have multiple database connections, you may need to start transactions on the other connections yourself.
268
+
267
269
  ### Reusing and extending forms
268
270
 
269
271
  You can descend form classes from other form classes and expose additional models or additional attributes on existing models.
@@ -5,7 +5,13 @@ module OnForm
5
5
  end
6
6
 
7
7
  def transaction(&block)
8
- with_transactions(backing_model_instances, &block)
8
+ backing_models = backing_model_instances
9
+
10
+ if backing_models.empty?
11
+ with_transactions([ActiveRecord::Base], &block)
12
+ else
13
+ with_transactions(backing_model_instances, &block)
14
+ end
9
15
  end
10
16
 
11
17
  def invalid?
@@ -1,3 +1,3 @@
1
1
  module OnForm
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: on_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Bryant
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel