yaaf 0.2.0 → 1.0.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
  SHA256:
3
- metadata.gz: 3a1722cf68a3ac8c7aa91f75205ff4885bae7a94fbf8764c94c2b0466959174a
4
- data.tar.gz: d35126b6b21dbd8e57fa67090ba8802323f4adbd61514cb50b0002adb48e2987
3
+ metadata.gz: 150ad0da1d4e4e76783819e3432e566ffae9be4894228d6dbca3540a1f8641b2
4
+ data.tar.gz: 01ad2b7331b363ded0cc2ee06c07dd63b1ce35917e614dc2bbd881963fd990aa
5
5
  SHA512:
6
- metadata.gz: 64ef092463adeacde6d6a4dd42c660ae005255de36ec6df071575d08086029dd6bd62bd212eba4add212eb437c402edb8f083758e3b1a7d4a61e628ec978d94b
7
- data.tar.gz: 26cda08a6ef4ad7dc741ade6ddce45e77720ecf979a9e788492c471ba486ed09b8a4791e81acaf3ac3ed8da875b5483928145ceec5e69c04060cdcb47f94ff41
6
+ metadata.gz: ad0fcc36cfeff881a36f9c89e2729ebb05523691e03546669091e322ef28f2b189a4d66f4141c48b11c19ff2fbbdfa917f0cdd34d1ca8c3a1383b4b4039b3801
7
+ data.tar.gz: c6a0535f1dfa8db916d2a2bb6d7c05b8d20272090440e124975775ab59f79d8bce4a2ac650109992bd5bc184c45491a28fbfdee7dd90e05abf09b2ded73502ae
data/README.md CHANGED
@@ -50,7 +50,7 @@ If you want to learn more about Form Objects you can check out [these great arti
50
50
 
51
51
  ### Why YAAF?
52
52
 
53
- - It is [64 lines long](https://github.com/rootstrap/yaaf/blob/master/lib/yaaf/form.rb#L64). As you can imagine, we did no magic in such a few lines of code, we just leveraged Rails modules in order to provide our form objects with a Rails-like behavior. You can review the code, it's easy to understand.
53
+ - It is [60 lines long](https://github.com/rootstrap/yaaf/blob/master/lib/yaaf/form.rb#L60). As you can imagine, we did no magic in such a few lines of code, we just leveraged Rails modules in order to provide our form objects with a Rails-like behavior. You can review the code, it's easy to understand.
54
54
 
55
55
  - It provides a similar API to `ActiveModel` models so you can treat them interchangeably.
56
56
 
data/lib/yaaf/form.rb CHANGED
@@ -30,18 +30,6 @@ module YAAF
30
30
 
31
31
  attr_accessor :models
32
32
 
33
- def promote_errors(model)
34
- if rails_version_less_than_6_1?
35
- model.errors.each do |attribute, message|
36
- errors.add(attribute, message)
37
- end
38
- else
39
- model.errors.each do |model_error|
40
- errors.add(model_error.attribute, model_error.message)
41
- end
42
- end
43
- end
44
-
45
33
  def save_in_transaction(options)
46
34
  ::ActiveRecord::Base.transaction do
47
35
  run_callbacks :save do
@@ -57,19 +45,16 @@ module YAAF
57
45
  end
58
46
 
59
47
  def validate_models
60
- models.each do |model|
61
- promote_errors(model) if model.invalid?
62
- end
48
+ models.each { |model| promote_errors(model) if model.invalid? }
49
+ end
50
+
51
+ def promote_errors(model)
52
+ errors.merge!(model.errors)
63
53
  end
64
54
 
65
55
  def handle_transaction_rollback(exception)
66
56
  run_callbacks :rollback
67
57
  raise exception
68
58
  end
69
-
70
- def rails_version_less_than_6_1?
71
- ActiveModel::VERSION::MAJOR < 6 ||
72
- ActiveModel::VERSION::MAJOR == 6 && ActiveModel::VERSION::MINOR.zero?
73
- end
74
59
  end
75
60
  end
data/lib/yaaf/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YAAF
4
- VERSION = '0.2.0'
4
+ VERSION = '1.0.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Manuel Ramallo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-01-28 00:00:00.000000000 Z
12
+ date: 2021-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -17,7 +17,7 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '4'
20
+ version: '5.2'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
23
  version: '7'
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: '4'
30
+ version: '5.2'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '7'
@@ -37,7 +37,7 @@ dependencies:
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '4'
40
+ version: '5.2'
41
41
  - - "<"
42
42
  - !ruby/object:Gem::Version
43
43
  version: '7'
@@ -47,7 +47,7 @@ dependencies:
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: '4'
50
+ version: '5.2'
51
51
  - - "<"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '7'