slim_form_object 1.0.8 → 1.0.9

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: 7efb3cc1fcf933252927331cc874dcda2b0624f9
4
- data.tar.gz: d2c0ba86d219f88539bde7f6544e85c8e0d8b8d0
3
+ metadata.gz: 5142bc15e772d2720401f7ab98cb4ff5d2f1d13e
4
+ data.tar.gz: 1e809535b0998762a3fd9d1070ad2f021ea349e9
5
5
  SHA512:
6
- metadata.gz: 91ba6f3a12ff713405f879cf03eaa7a82351965599b675b670d9cd266c15e0a9b07ab44c68e25fdd48720ab7d9338b334889368710537c6fc30e76aa12698614
7
- data.tar.gz: 49ec93ce2e22bc873881266f5e6fd6019b1ab36f6d2505016753c46fe49532fdf3a068164e9fa52ee249817b381fdb0ef4ff28c5e873c721f8c2130c112c5737
6
+ metadata.gz: 7cb7ec4828b5df9108064545400312aa20106a47ce4a1f22d215b94670077cf1f6af367cd4406867977082597a031d093734e15c2b6ce403ead550af72bc65c9
7
+ data.tar.gz: 716e73b7e57efe5db0f283300d2f8d2002dd986893a910cfc67f92431d9896d39df81b0ccf11bffc720d23b3f71821e7e85afd750dcaebbc6c821be5708be2f2
@@ -72,6 +72,7 @@ module SlimFormObject
72
72
  end
73
73
 
74
74
  def initialize(params: {})
75
+ require_extensions
75
76
  self.params = params
76
77
  get_or_add_default_objects
77
78
  end
@@ -98,6 +99,10 @@ module SlimFormObject
98
99
 
99
100
  private
100
101
 
102
+ def require_extensions
103
+ require "slim_form_object/form_helpers/extension_actionview"
104
+ end
105
+
101
106
  def apply
102
107
  assign = Assign.new(self)
103
108
  @hash_objects_for_save = assign.apply_parameters
@@ -13,22 +13,32 @@ module SlimFormObject
13
13
 
14
14
  def save
15
15
  if form_object.valid?
16
- ActiveRecord::Base.transaction do
17
- form_object.before_save_block.call(form_object)
18
- save_main_objects
19
- save_nested_objects
20
- form_object.after_save_block.call(form_object)
21
- end
16
+ save_all
22
17
  return true
23
18
  end
24
-
25
19
  false
26
20
  rescue
27
21
  false
28
22
  end
29
23
 
24
+ def save!
25
+ if form_object.valid?
26
+ save_all
27
+ end
28
+ true
29
+ end
30
+
30
31
  private
31
32
 
33
+ def save_all
34
+ ActiveRecord::Base.transaction do
35
+ form_object.before_save_block.call(form_object)
36
+ save_main_objects
37
+ save_nested_objects
38
+ form_object.after_save_block.call(form_object)
39
+ end
40
+ end
41
+
32
42
  def save_main_objects
33
43
  objects = Array.new(hash_objects_for_save[:objects])
34
44
  while object_1 = objects.delete( objects[0] )
@@ -46,8 +56,6 @@ module SlimFormObject
46
56
  end
47
57
  end
48
58
 
49
-
50
-
51
59
  def save_objects(object_1, object_2)
52
60
  object_for_save = to_bind_models(object_1, object_2)
53
61
  save_object(object_for_save)
@@ -72,7 +80,7 @@ module SlimFormObject
72
80
  end
73
81
 
74
82
  def save_last_model_if_not_associations(object_1)
75
- association_trigger = false
83
+ association_trigger = false
76
84
  hash_objects_for_save[:objects].each { |object_2| association_trigger = true if get_association(object_1.class, object_2.class) }
77
85
  object_1.save unless association_trigger
78
86
  rescue
@@ -1,3 +1,3 @@
1
1
  module SlimFormObject
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
@@ -1,5 +1,4 @@
1
1
  require "slim_form_object/version"
2
- require "slim_form_object/form_helpers/extension_actionview"
3
2
  require "slim_form_object/helpers"
4
3
  require "slim_form_object/validator"
5
4
  require "slim_form_object/processing"
@@ -3,6 +3,7 @@ require 'helpers/models'
3
3
 
4
4
  class TestModule < SlimFormObject::Base
5
5
  init_models TestOneModel, TestTwoModel, TestThreeModel, TestFourModel
6
+ not_save_empty_object_for
6
7
  end
7
8
 
8
9
  describe TestModule, enviroment: :test do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim_form_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - woodcrust
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  requirements: []
202
202
  rubyforge_project:
203
- rubygems_version: 2.5.1
203
+ rubygems_version: 2.6.12
204
204
  signing_key:
205
205
  specification_version: 4
206
206
  summary: This is form object