card-mod-virtual 0.13.2 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/card/virtual.rb +18 -27
- data/set/abstract/virtual_cache.rb +23 -15
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1faaea40397c0d5da4eb68f26af697f89f80c38f26185988cac81f01eb0cc938
|
4
|
+
data.tar.gz: 1a5e126f6857daff50088c18e6401b5d9d56c831b4c0b1da56cd0d0b05db6419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c76342d146a4fc7d1c17c20b42716971c84f23111b8939d15770041f0f367c463444033f6654a0dcbcdbd8a0ab2755c7e9b586325d6123be082efc3728f6963
|
7
|
+
data.tar.gz: 8d959e2aa0ce142094980c4cdb1abe6a7f2b2df503a4039129b9c41095cb6d0582055f454826e5a574849a4bfc84f02ce90ba275bce8ede271bc77905c4949ec
|
data/lib/card/virtual.rb
CHANGED
@@ -6,53 +6,44 @@ class Card
|
|
6
6
|
# the card_virtuals table.
|
7
7
|
class Virtual < Cardio::Record
|
8
8
|
def update new_content
|
9
|
-
update!
|
9
|
+
content == new_content ? touch : update!(content: new_content)
|
10
10
|
new_content
|
11
11
|
end
|
12
12
|
|
13
13
|
class << self
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
create! left_id: left_id(card),
|
18
|
-
right_id: right_id(card),
|
19
|
-
left_key: card.name.left_key,
|
20
|
-
content: virtual_content
|
21
|
-
end
|
22
|
-
|
23
|
-
def create_or_update card, virtual_content
|
24
|
-
if (virtual_card = find_by_card(card))
|
25
|
-
virtual_card.update virtual_content
|
26
|
-
else
|
27
|
-
create card, virtual_content
|
14
|
+
def fetch card
|
15
|
+
cache.fetch card.key do
|
16
|
+
find_by_card(card) || create(card)
|
28
17
|
end
|
29
18
|
end
|
30
19
|
|
31
|
-
def
|
32
|
-
|
20
|
+
def save card
|
21
|
+
virt = find_by_card card
|
22
|
+
virt ? virt.update(card.virtual_content) : create(card)
|
33
23
|
end
|
34
24
|
|
35
|
-
def
|
36
|
-
find_by_card(card)
|
25
|
+
def delete card
|
26
|
+
find_by_card(card)&.delete
|
37
27
|
end
|
38
28
|
|
39
|
-
|
40
|
-
virtual = find_by_card(card)
|
41
|
-
return create(card) unless virtual
|
29
|
+
private
|
42
30
|
|
43
|
-
|
31
|
+
def cache
|
32
|
+
Card::Cache[Virtual]
|
44
33
|
end
|
45
34
|
|
46
|
-
def
|
47
|
-
|
35
|
+
def create card
|
36
|
+
validate_card card
|
37
|
+
create! left_id: left_id(card),
|
38
|
+
right_id: right_id(card),
|
39
|
+
left_key: card.name.left_key,
|
40
|
+
content: card.virtual_content
|
48
41
|
end
|
49
42
|
|
50
43
|
def find_by_card card
|
51
44
|
where_card(card).take
|
52
45
|
end
|
53
46
|
|
54
|
-
private
|
55
|
-
|
56
47
|
def where_card card
|
57
48
|
query = { right_id: right_id(card) }
|
58
49
|
if (lid = left_id(card))
|
@@ -4,32 +4,40 @@ def virtual?
|
|
4
4
|
new?
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def followable?
|
12
|
-
false
|
7
|
+
# the content to be cached
|
8
|
+
# (can be overridden)
|
9
|
+
def virtual_content
|
10
|
+
attributes["db_content"]
|
13
11
|
end
|
14
12
|
|
15
13
|
def db_content
|
16
|
-
|
14
|
+
Virtual.fetch(self)&.content
|
17
15
|
end
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
def generate_virtual_content
|
22
|
-
template&.db_content
|
17
|
+
def updated_at
|
18
|
+
Virtual.fetch(self)&.updated_at
|
23
19
|
end
|
24
20
|
|
25
|
-
event :save_virtual_content, :prepare_to_store, on: :save
|
26
|
-
|
21
|
+
event :save_virtual_content, :prepare_to_store, on: :save do
|
22
|
+
Virtual.save self
|
27
23
|
abort :success
|
28
24
|
end
|
29
25
|
|
30
26
|
event :delete_virtual_content, :prepare_to_store, on: :delete do
|
31
|
-
|
32
|
-
abort :success
|
27
|
+
Virtual.delete self
|
28
|
+
abort :success unless real?
|
29
|
+
end
|
30
|
+
|
31
|
+
# TODO: confirm that the following are needed (and if so, explain why)
|
32
|
+
# in theory, if we always abort, we'll never trigger history/follow events,
|
33
|
+
# and we'll never have a card to delete, no?
|
34
|
+
|
35
|
+
def history?
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
def followable?
|
40
|
+
false
|
33
41
|
end
|
34
42
|
|
35
43
|
def delete
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card-mod-virtual
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-01-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: card
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.104.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
28
|
+
version: 1.104.1
|
29
29
|
description: ''
|
30
30
|
email:
|
31
31
|
- info@decko.org
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
63
|
+
rubygems_version: 3.2.15
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: virtual
|