shiftable 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/shiftable/collection.rb +2 -2
- data/lib/shiftable/mod_signature.rb +9 -6
- data/lib/shiftable/shifting.rb +9 -4
- data/lib/shiftable/shifting_record.rb +2 -2
- data/lib/shiftable/single.rb +2 -2
- data/lib/shiftable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae22d0c5730e6bde9ad658ee1b8deddb2ca83e8d09cccc560945faf51c796b6a
|
4
|
+
data.tar.gz: b8ef6d21e4273b247a4287a31059eb02bed5bafaf3941562ddfc78f798fd139a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19ab8c6178402cb18788424023d380672a8d4c7597b432703b79f73900950cf353d8fe85702a0fbd09387f3dd61c4276ba69fe0e9e99499bc77b52d8c9bc3b0b
|
7
|
+
data.tar.gz: 66d90707da9952a116619e7421127f2c6bad0f4b74558e24ea0da97d7e5670a17960dfabf92ece49ab9cf10bcc60deb9f556f25fc835df656ba9ad1f0f17aa82
|
data/CHANGELOG.md
CHANGED
data/lib/shiftable/collection.rb
CHANGED
@@ -73,8 +73,8 @@ module Shiftable
|
|
73
73
|
define_method(:"#{prefix}shift_#{type}_column") do
|
74
74
|
signature.send("shift_#{type}_column")
|
75
75
|
end
|
76
|
-
define_method(:"#{prefix}shift_#{type}") do |shift_to:, shift_from
|
77
|
-
signature.shift_data!(shift_to: shift_to, shift_from: shift_from)
|
76
|
+
define_method(:"#{prefix}shift_#{type}") do |shift_to:, shift_from:, bang: false|
|
77
|
+
signature.shift_data!(shift_to: shift_to, shift_from: shift_from, bang: bang)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -75,14 +75,15 @@ module Shiftable
|
|
75
75
|
associations[:has_many]
|
76
76
|
end
|
77
77
|
|
78
|
-
def shift_data!(shift_to:, shift_from:)
|
78
|
+
def shift_data!(shift_to:, shift_from:, bang: false)
|
79
79
|
validate_relationships
|
80
80
|
shifting_rel = ShiftingRelation.new(
|
81
81
|
to: shift_to,
|
82
82
|
from: shift_from,
|
83
83
|
column: shift_column,
|
84
84
|
base: base,
|
85
|
-
wrapper: wrapper
|
85
|
+
wrapper: wrapper,
|
86
|
+
bang: bang
|
86
87
|
)
|
87
88
|
shifting_rel.shift do
|
88
89
|
before_shift&.call(shifting_rel)
|
@@ -96,7 +97,7 @@ module Shiftable
|
|
96
97
|
# associations[:has_many]
|
97
98
|
# end
|
98
99
|
|
99
|
-
def shift_data!(shift_to:, shift_from:)
|
100
|
+
def shift_data!(shift_to:, shift_from:, bang: false)
|
100
101
|
validate_relationships
|
101
102
|
shifting_rel = ShiftingPolymorphicRelation.new(
|
102
103
|
to: shift_to,
|
@@ -107,7 +108,8 @@ module Shiftable
|
|
107
108
|
id_column: shift_pcx_column
|
108
109
|
},
|
109
110
|
base: base,
|
110
|
-
wrapper: wrapper
|
111
|
+
wrapper: wrapper,
|
112
|
+
bang: bang
|
111
113
|
)
|
112
114
|
shifting_rel.shift do
|
113
115
|
before_shift&.call(shifting_rel)
|
@@ -125,14 +127,15 @@ module Shiftable
|
|
125
127
|
options[:precheck]
|
126
128
|
end
|
127
129
|
|
128
|
-
def shift_data!(shift_to:, shift_from:)
|
130
|
+
def shift_data!(shift_to:, shift_from:, bang: false)
|
129
131
|
validate_relationships
|
130
132
|
shifting = ShiftingRecord.new(
|
131
133
|
to: shift_to,
|
132
134
|
from: shift_from,
|
133
135
|
column: shift_column,
|
134
136
|
base: base,
|
135
|
-
wrapper: wrapper
|
137
|
+
wrapper: wrapper,
|
138
|
+
bang: bang
|
136
139
|
) do
|
137
140
|
!precheck || !shift_to.send(has_rel)
|
138
141
|
end
|
data/lib/shiftable/shifting.rb
CHANGED
@@ -3,9 +3,13 @@
|
|
3
3
|
module Shiftable
|
4
4
|
# Gets data to be shifted
|
5
5
|
class Shifting
|
6
|
-
|
6
|
+
# Public API
|
7
|
+
attr_accessor :result, :bang, :shift_all_wrapper, :shift_each_wrapper
|
8
|
+
attr_reader :to, :from
|
9
|
+
# Internal API
|
10
|
+
attr_reader :column, :base, :run_save
|
7
11
|
|
8
|
-
def initialize(to:, from:, column:, base:, wrapper:)
|
12
|
+
def initialize(to:, from:, column:, base:, wrapper:, bang:)
|
9
13
|
@to = to
|
10
14
|
@from = from
|
11
15
|
@column = column
|
@@ -16,6 +20,7 @@ module Shiftable
|
|
16
20
|
@run_save = true
|
17
21
|
@shift_all_wrapper = wrapper[:all]
|
18
22
|
@shift_each_wrapper = wrapper[:each]
|
23
|
+
@bang = bang
|
19
24
|
end
|
20
25
|
|
21
26
|
# def found?
|
@@ -47,11 +52,11 @@ module Shiftable
|
|
47
52
|
if shift_each_wrapper
|
48
53
|
each do |rec|
|
49
54
|
shift_each_wrapper.call(rec) do
|
50
|
-
rec.save
|
55
|
+
bang ? rec.save! : rec.save
|
51
56
|
end
|
52
57
|
end
|
53
58
|
else
|
54
|
-
each(&:save)
|
59
|
+
bang ? each(&:save!) : each(&:save)
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
data/lib/shiftable/single.rb
CHANGED
@@ -73,8 +73,8 @@ module Shiftable
|
|
73
73
|
define_method(:"#{prefix}shift_column") do
|
74
74
|
signature.send("shift_#{signature.type}_column")
|
75
75
|
end
|
76
|
-
define_method(:"#{prefix}shift_single") do |shift_to:, shift_from
|
77
|
-
signature.shift_data!(shift_to: shift_to, shift_from: shift_from)
|
76
|
+
define_method(:"#{prefix}shift_single") do |shift_to:, shift_from:, bang: false|
|
77
|
+
signature.shift_data!(shift_to: shift_to, shift_from: shift_from, bang: bang)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
data/lib/shiftable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shiftable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|