garland 1.0.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/garland_rails.rb +19 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2b288498ddb5433e1531d660e8a016131d85965
|
4
|
+
data.tar.gz: 5f90325f1edf6ebb8c90e7c7c227fb60dc222f23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8771347f6b30260954a864529e7b9943e74c4d7ba23c5d116bb953b043290d075c69f6c669337f4dcc9744b223d22b1c71e0558a5c7d52df4ec44071acffaab7
|
7
|
+
data.tar.gz: 8e849c82f4e935bbfb1e751f2f9e7401134b41d18c729b3907c7d46a2baf05b37fa7158472851a4e80951a5cf837fad10ceabca76073f6dca71b7588ccea6e20
|
data/lib/garland_rails.rb
CHANGED
@@ -107,6 +107,20 @@ module GarlandRails
|
|
107
107
|
self.find_by(id: head.previous_id)
|
108
108
|
end
|
109
109
|
|
110
|
+
def next
|
111
|
+
Garland.find(self.next_id)
|
112
|
+
end
|
113
|
+
|
114
|
+
def previous
|
115
|
+
Garland.find(self.previous_id)
|
116
|
+
end
|
117
|
+
|
118
|
+
def safe_eval_entity
|
119
|
+
return nil unless self.entity =~ /\[.*\]/ || self.entity =~ /{.*}/
|
120
|
+
|
121
|
+
eval(self.entity)
|
122
|
+
end
|
123
|
+
|
110
124
|
def self.table_type(record)
|
111
125
|
record.class.name
|
112
126
|
end
|
@@ -165,7 +179,7 @@ module GarlandRails
|
|
165
179
|
last_diff = self.find_by(id: head.previous_id)
|
166
180
|
common_props = self._split_belongs_to(belongs_to)
|
167
181
|
|
168
|
-
diff = HashDiffSym.diff(
|
182
|
+
diff = HashDiffSym.diff(head.safe_eval_entity, hash)
|
169
183
|
return unless diff.any?
|
170
184
|
|
171
185
|
new_diff_props = common_props.merge(
|
@@ -221,19 +235,19 @@ module GarlandRails
|
|
221
235
|
return false unless tail && head
|
222
236
|
|
223
237
|
current_bulb = tail
|
224
|
-
current_hash =
|
238
|
+
current_hash = tail.safe_eval_entity
|
225
239
|
items_counted = 1
|
226
240
|
while current_bulb.next_id do
|
227
241
|
items_counted += 1
|
228
|
-
current_bulb =
|
242
|
+
current_bulb = current_bulb.next
|
229
243
|
if current_bulb.entity_type == DIFF
|
230
|
-
current_hash = HashDiffSym.patch!(current_hash,
|
244
|
+
current_hash = HashDiffSym.patch!(current_hash, current_bulb.safe_eval_entity)
|
231
245
|
else
|
232
246
|
break
|
233
247
|
end
|
234
248
|
end
|
235
249
|
|
236
|
-
items_counted == self.thread(belongs_to).size && current_hash ==
|
250
|
+
items_counted == self.thread(belongs_to).size && current_hash == head.safe_eval_entity
|
237
251
|
end
|
238
252
|
|
239
253
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garland
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Morozov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashdiff_sym
|