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 +4 -4
- data/lib/slim_form_object/processing.rb +5 -0
- data/lib/slim_form_object/saver.rb +18 -10
- data/lib/slim_form_object/version.rb +1 -1
- data/lib/slim_form_object.rb +0 -1
- data/spec/slim_form_object_spec.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5142bc15e772d2720401f7ab98cb4ff5d2f1d13e
|
4
|
+
data.tar.gz: 1e809535b0998762a3fd9d1070ad2f021ea349e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
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
|
data/lib/slim_form_object.rb
CHANGED
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.
|
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-
|
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.
|
203
|
+
rubygems_version: 2.6.12
|
204
204
|
signing_key:
|
205
205
|
specification_version: 4
|
206
206
|
summary: This is form object
|