card 1.99.5 → 1.99.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +1 -1
- data/lib/card.rb +13 -23
- data/lib/card/act_manager.rb +1 -0
- data/lib/card/act_manager/event_delay.rb +10 -5
- data/lib/card/act_manager/subdirector_array.rb +2 -0
- data/lib/card/auth/current.rb +0 -2
- data/lib/card/cache/prepopulate.rb +4 -4
- data/lib/card/env.rb +9 -53
- data/lib/card/env/location.rb +15 -2
- data/lib/card/env/request_assignments.rb +24 -0
- data/lib/card/env/serialization.rb +24 -0
- data/lib/card/env/slot_options.rb +30 -0
- data/lib/card/format/error.rb +6 -1
- data/lib/card/mod/loader/set_pattern_loader.rb +5 -1
- data/lib/card/model/save_helper.rb +5 -1
- data/lib/card/set/event/delayed_event.rb +49 -9
- data/lib/card/set/event/options.rb +1 -0
- data/lib/card/set/pattern/base.rb +18 -0
- data/lib/card/subcards.rb +11 -8
- data/lib/card/subcards/add.rb +7 -4
- data/lib/card/view/cache/cache_action.rb +1 -1
- data/lib/card/view/classy.rb +9 -9
- data/lib/card/view/options/voo_api.rb +0 -8
- data/mod/account/set/all/account.rb +2 -2
- data/mod/account/spec/set/right/account_spec.rb +2 -2
- data/mod/account/spec/set/type/signup_spec.rb +1 -1
- data/mod/basic_formats/set/all/head.rb +4 -2
- data/mod/basic_formats/set/all/rss.rb +1 -1
- data/mod/bootstrap/lib/card/lazy_tab.rb +37 -0
- data/mod/bootstrap/lib/card/tab.rb +76 -0
- data/mod/bootstrap/set/all/bootstrap/dropdown.rb +0 -1
- data/mod/bootstrap/set/all/bootstrap/tabs.rb +33 -124
- data/mod/bootstrap/set/all/bootstrap/tabs/tab_panel.haml +7 -0
- data/mod/carrierwave/set/abstract/attachment.rb +1 -1
- data/mod/carrierwave/set/abstract/attachment/upload_cache.rb +1 -1
- data/mod/core/lib/card/rule.rb +227 -0
- data/mod/core/set/all/actify.rb +16 -2
- data/mod/core/set/all/assign_attributes.rb +2 -2
- data/mod/core/set/all/cache.rb +4 -0
- data/mod/core/set/all/event_conditions.rb +58 -39
- data/mod/core/set/all/fetch.rb +1 -1
- data/mod/core/set/all/fetch_helper.rb +5 -13
- data/mod/core/set/all/initialize.rb +6 -6
- data/mod/core/set/all/name_events.rb +2 -3
- data/mod/core/set/all/rename.rb +9 -5
- data/mod/core/set/all/rules.rb +3 -228
- data/mod/core/set/all/tabs.rb +4 -3
- data/mod/core/set/all/update_read_rules.rb +1 -1
- data/mod/core/set_pattern/08_type_plus_right.rb +1 -2
- data/mod/core/spec/set/all/event_conditions_spec.rb +3 -3
- data/mod/core/spec/set/all/fetch_helper_spec.rb +6 -0
- data/mod/core/spec/set/all/references_spec.rb +9 -0
- data/mod/core/spec/set/all/rules_spec.rb +1 -1
- data/mod/developer/set/right/debug.rb +13 -14
- data/mod/edit/set/all/bridge.rb +7 -7
- data/mod/edit/set/all/bridge/tab_visibility.rb +2 -2
- data/mod/follow/set/all/follow/followed_by.rb +1 -2
- data/mod/follow/set/all/follow/follower_ids.rb +15 -3
- data/mod/follow/set/all/notify.rb +1 -5
- data/mod/follow/set/type_plus_right/user/follow.rb +4 -7
- data/mod/google_analytics/set/all/google_analytics.rb +1 -1
- data/mod/history/lib/card/act.rb +1 -1
- data/mod/history/set/all/history.rb +23 -17
- data/mod/history/set/all/history/acts.rb +0 -4
- data/mod/machines/file/all_script_machine_output/file.js +69 -38418
- data/mod/machines/file/all_style_machine_output/file.css +1 -1
- data/mod/machines/file/script_html5shiv_printshiv_machine_output/file.js +1 -1
- data/mod/machines/lib/javascript/decko/filter_items.js.coffee +4 -4
- data/mod/machines/lib/javascript/decko/nest_editor_name.js.coffee +1 -1
- data/mod/machines/lib/javascript/decko/selectable_filtered_content.js.coffee +12 -0
- data/mod/machines/lib/javascript/decko/slotter.js.coffee +1 -1
- data/mod/machines/lib/stylesheets/style_cards.scss +1 -1
- data/mod/machines/set/abstract/machine/output_update.rb +12 -4
- data/mod/machines/set/self/script_decko.rb +1 -1
- data/mod/pointer/set/abstract/00_paging_params.rb +1 -3
- data/mod/pointer/set/abstract/02_pointer/events.rb +1 -0
- data/mod/recaptcha/set/all/recaptcha.rb +1 -1
- data/mod/recaptcha/set/self/admin_info.rb +2 -3
- data/mod/rules/set/type/set.rb +1 -1
- data/mod/search/set/abstract/00_filter_helper.rb +2 -4
- data/mod/search/set/abstract/02_search_params.rb +1 -1
- data/mod/search/set/abstract/03_filter.rb +2 -0
- data/mod/search/set/abstract/03_filter/selectable_filtered_content.haml +2 -0
- data/mod/search/template/abstract/search/checkbox_item.haml +2 -3
- data/mod/settings/set/right/read.rb +1 -1
- data/mod/standard/set/all/rich_html/error.rb +1 -1
- data/mod/standard/set/all/rich_html/menu.rb +1 -1
- data/mod/standard/set/all/rich_html/show.rb +8 -0
- data/mod/tinymce_editor/set/all/reference_editor/nest_editor.rb +6 -8
- metadata +13 -5
- data/lib/card/tasks/card/seed.rake +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4f675190befef26d884a69d4e4e36901739bd130a68e20a68c430a3cf2ea56c
|
4
|
+
data.tar.gz: 54ae4a1da649e984b2c62a7ea430b4861c4b9d64a8f2004efff6f3000fc70349
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93b245586c081b199f4a3b5a37a2b7b1265eb2b94bdac410a9cd388a0d66913ce5eced96220c79b4d504058fab1adb0d17cf736a0aa78320cc5af03ce7e4a909
|
7
|
+
data.tar.gz: 413929179c4ac6c258b79600dc9a5de24141dcb5b6d6cc7ccaed53d77e066150225dcbdbbf09d50c863b58578ec9613bbee8374db4ba0e6ebf32a4121b75bcfe
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.6
|
@@ -85,7 +85,7 @@ class AddEmailCards < Card::Migration::Core
|
|
85
85
|
end
|
86
86
|
|
87
87
|
wagn_bot = Card[:wagn_bot].account.email.present? ? Card[:wagn_bot].name : nil
|
88
|
-
token_emails_from = Card.global_setting("*invite+*from") || wagn_bot || "_user"
|
88
|
+
token_emails_from = Card::Rule.global_setting("*invite+*from") || wagn_bot || "_user"
|
89
89
|
["verification email", "password reset email"].each do |token_email_template_name|
|
90
90
|
Card.create! name: "#{token_email_template_name}+#{Card[:from].name}", content: token_emails_from
|
91
91
|
end
|
data/lib/card.rb
CHANGED
@@ -104,41 +104,31 @@ class Card < ApplicationRecord
|
|
104
104
|
has_many :actions, -> { where(draft: [nil, false]).order :id }
|
105
105
|
has_many :drafts, -> { where(draft: true).order :id }, class_name: :Action
|
106
106
|
|
107
|
-
cattr_accessor :set_patterns, :
|
108
|
-
self.set_patterns = []
|
109
|
-
|
110
|
-
# attributes that ActiveJob can handle
|
111
|
-
def self.serializable_attr_accessor *args
|
112
|
-
self.serializable_attributes = args
|
113
|
-
attr_accessor(*args)
|
114
|
-
end
|
107
|
+
cattr_accessor :set_patterns, :action_specific_attributes, :set_specific_attributes
|
115
108
|
|
116
|
-
|
109
|
+
self.set_patterns = []
|
110
|
+
self.action_specific_attributes = [
|
117
111
|
:action, :supercard, :superleft,
|
118
112
|
:current_action,
|
119
|
-
|
120
|
-
:update_referers, # wrong mechanism for this
|
121
|
-
:update_all_users, # if the above is wrong then this one too
|
122
|
-
:silent_change, # and this probably too
|
123
|
-
# :remove_rule_stash,
|
113
|
+
|
124
114
|
:last_action_id_before_edit,
|
125
115
|
:only_storage_phase, # used to save subcards
|
126
116
|
:changed_attributes,
|
117
|
+
|
127
118
|
:skip, # skip event(s) for all cards in act
|
128
119
|
:skip_in_action, # skip event for just this card
|
129
120
|
:trigger, # trigger event(s) for all cards in act
|
130
|
-
:trigger_in_action
|
131
|
-
)
|
121
|
+
:trigger_in_action, # trigger event for just this card
|
132
122
|
|
133
|
-
|
134
|
-
alias_method :skip_event_in_action, :skip_in_action
|
135
|
-
alias_method :trigger_event, :trigger
|
136
|
-
alias_method :trigger_event_in_action, :trigger_in_action
|
123
|
+
:comment, # obviated soon
|
137
124
|
|
138
|
-
|
139
|
-
|
140
|
-
|
125
|
+
# TODO: refactor following to use skip/trigger
|
126
|
+
:update_referers, # wrong mechanism for this
|
127
|
+
:update_all_users, # if the above is wrong then this one too
|
128
|
+
:silent_change # and this probably too
|
129
|
+
]
|
141
130
|
|
131
|
+
attr_accessor(*action_specific_attributes)
|
142
132
|
attr_accessor :follower_stash
|
143
133
|
|
144
134
|
STAGE_CALLBACKS = [
|
data/lib/card/act_manager.rb
CHANGED
@@ -26,16 +26,21 @@ class Card
|
|
26
26
|
# event processed by ActiveJob.
|
27
27
|
# This is the improvised resetup to get subcards working.
|
28
28
|
def contextualize_for_delay act_id, card, env, auth, &block
|
29
|
-
self.act = Act.find act_id if act_id
|
30
29
|
with_env_and_auth env, auth do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
if act_id && (self.act = Act.find act_id)
|
31
|
+
run_job_with_act act, card, &block
|
32
|
+
else
|
33
|
+
yield
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
38
|
+
def run_job_with_act act, card, &block
|
39
|
+
run_act(act.card || card) do
|
40
|
+
act_card.director.run_delayed_event act, &block
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
39
44
|
def with_env_and_auth env, auth
|
40
45
|
Card::Auth.with auth do
|
41
46
|
Card::Env.with env do
|
@@ -19,6 +19,8 @@ class Card
|
|
19
19
|
card = card.card if card.is_a? StageDirector
|
20
20
|
each { |dir| return dir if dir.card == card }
|
21
21
|
dir = ActManager.fetch card, parent: @parent
|
22
|
+
return dir if dir.main
|
23
|
+
|
22
24
|
dir.replace_card card if dir.card != card
|
23
25
|
dir.main = false
|
24
26
|
dir.parent = @parent
|
data/lib/card/auth/current.rb
CHANGED
@@ -27,10 +27,10 @@ class Card
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def prepopulate_rule_caches
|
30
|
-
prepopulate_cache("RULES") { Card.rule_cache }
|
31
|
-
prepopulate_cache("READRULES") { Card.read_rule_cache }
|
32
|
-
prepopulate_cache("USER_IDS") { Card.user_ids_cache }
|
33
|
-
prepopulate_cache("
|
30
|
+
prepopulate_cache("RULES") { Card::Rule.rule_cache }
|
31
|
+
prepopulate_cache("READRULES") { Card::Rule.read_rule_cache }
|
32
|
+
prepopulate_cache("USER_IDS") { Card::Rule.user_ids_cache }
|
33
|
+
prepopulate_cache("RULE_KEYS") { Card::Rule.rule_keys_cache }
|
34
34
|
end
|
35
35
|
|
36
36
|
# def prepopulate_card_cache
|
data/lib/card/env.rb
CHANGED
@@ -5,10 +5,9 @@ class Card
|
|
5
5
|
# Env can differ for each request; Card.config should not.
|
6
6
|
module Env
|
7
7
|
extend LocationHistory
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
]
|
8
|
+
extend RequestAssignments
|
9
|
+
extend SlotOptions
|
10
|
+
extend Serialization
|
12
11
|
|
13
12
|
class << self
|
14
13
|
def reset args={}
|
@@ -38,13 +37,11 @@ class Card
|
|
38
37
|
self[:params] ||= {}
|
39
38
|
end
|
40
39
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
opts.merge! shortcut_slot_opts
|
47
|
-
opts.deep_symbolize_keys.slice(*Card::View::Options.slot_keys)
|
40
|
+
def hash hashish
|
41
|
+
case hashish
|
42
|
+
when Hash then hashish.clone
|
43
|
+
when ActionController::Parameters then hashish.to_unsafe_h
|
44
|
+
else {}
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
@@ -65,7 +62,7 @@ class Card
|
|
65
62
|
end
|
66
63
|
|
67
64
|
def localhost?
|
68
|
-
self[:host]
|
65
|
+
self[:host]&.match?(/^localhost/)
|
69
66
|
end
|
70
67
|
|
71
68
|
def ajax?
|
@@ -76,38 +73,8 @@ class Card
|
|
76
73
|
!self[:controller] || self[:html]
|
77
74
|
end
|
78
75
|
|
79
|
-
def serialize
|
80
|
-
@env.select { |k, _v| SERIALIZABLE_ATTRIBUTES.include?(k) }
|
81
|
-
end
|
82
|
-
|
83
|
-
# @param serialized_env [Hash]
|
84
|
-
def with serialized_env
|
85
|
-
tmp_env = serialize if @env
|
86
|
-
@env ||= {}
|
87
|
-
@env.update serialized_env
|
88
|
-
yield
|
89
|
-
ensure
|
90
|
-
@env.update tmp_env if tmp_env
|
91
|
-
end
|
92
|
-
|
93
76
|
private
|
94
77
|
|
95
|
-
def assign_ajax c
|
96
|
-
c.request.xhr? || c.request.params[:simulate_xhr]
|
97
|
-
end
|
98
|
-
|
99
|
-
def assign_html c
|
100
|
-
[nil, "html"].member?(c.params[:format])
|
101
|
-
end
|
102
|
-
|
103
|
-
def assign_host c
|
104
|
-
Card.config.override_host || c.request.env["HTTP_HOST"]
|
105
|
-
end
|
106
|
-
|
107
|
-
def assign_protocol c
|
108
|
-
Card.config.override_protocol || c.request.protocol
|
109
|
-
end
|
110
|
-
|
111
78
|
def method_missing method_id, *args
|
112
79
|
case args.length
|
113
80
|
when 0 then self[method_id]
|
@@ -115,17 +82,6 @@ class Card
|
|
115
82
|
else super
|
116
83
|
end
|
117
84
|
end
|
118
|
-
|
119
|
-
def shortcut_slot_opts
|
120
|
-
opts = {}
|
121
|
-
opts[:size] = params[:size].to_sym if params[:size]
|
122
|
-
opts[:items] = { view: params[:item].to_sym } if slot_items_shortcut?
|
123
|
-
opts
|
124
|
-
end
|
125
|
-
|
126
|
-
def slot_items_shortcut?
|
127
|
-
params[:item].present? && !params.dig(:slot, :items, :view).present?
|
128
|
-
end
|
129
85
|
end
|
130
86
|
end
|
131
87
|
end
|
data/lib/card/env/location.rb
CHANGED
@@ -21,10 +21,23 @@ class Card
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def protocol_and_host
|
24
|
-
Card.config.protocol_and_host || "#{
|
24
|
+
Card.config.protocol_and_host || "#{Env[:protocol]}#{Env[:host]}"
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
def cardname_from_url url
|
28
|
+
m = url.match cardname_from_url_regexp
|
29
|
+
m ? Card::Name[m[:mark]] : nil
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def cardname_from_url_regexp
|
35
|
+
return unless Env[:host]
|
36
|
+
|
37
|
+
%r{#{Regexp.escape Env[:host]}/(?<mark>[^\?]+)}
|
38
|
+
end
|
39
|
+
|
40
|
+
extend Location # allows calls on Location constant, eg Location.card_url
|
28
41
|
end
|
29
42
|
end
|
30
43
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Card
|
2
|
+
module Env
|
3
|
+
# environmental variables assigned based on request
|
4
|
+
module RequestAssignments
|
5
|
+
private
|
6
|
+
|
7
|
+
def assign_ajax c
|
8
|
+
c.request.xhr? || c.request.params[:simulate_xhr]
|
9
|
+
end
|
10
|
+
|
11
|
+
def assign_html c
|
12
|
+
[nil, "html"].member?(c.params[:format])
|
13
|
+
end
|
14
|
+
|
15
|
+
def assign_host c
|
16
|
+
Card.config.override_host || c.request.env["HTTP_HOST"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def assign_protocol c
|
20
|
+
Card.config.override_protocol || c.request.protocol
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Card
|
2
|
+
module Env
|
3
|
+
# serializing environment (eg for delayed jobs)
|
4
|
+
module Serialization
|
5
|
+
SERIALIZABLE_ATTRIBUTES = ::Set.new %i[
|
6
|
+
main_name params ip ajax html host protocol salt
|
7
|
+
]
|
8
|
+
|
9
|
+
# @param serialized_env [Hash]
|
10
|
+
def with serialized_env
|
11
|
+
tmp_env = serialize if @env
|
12
|
+
@env ||= {}
|
13
|
+
@env.update serialized_env
|
14
|
+
yield
|
15
|
+
ensure
|
16
|
+
@env.update tmp_env if tmp_env
|
17
|
+
end
|
18
|
+
|
19
|
+
def serialize
|
20
|
+
@env.select { |k, _v| SERIALIZABLE_ATTRIBUTES.include?(k) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Card
|
2
|
+
module Env
|
3
|
+
# slot-related environmental variable handling
|
4
|
+
module SlotOptions
|
5
|
+
def slot_opts
|
6
|
+
# FIXME: upgrade to safe parameters
|
7
|
+
self[:slot_opts] ||= interpret_slot_options
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def interpret_slot_options
|
13
|
+
opts = hash params[:slot]
|
14
|
+
opts.merge! shortcut_slot_opts
|
15
|
+
opts.deep_symbolize_keys.slice(*Card::View::Options.slot_keys)
|
16
|
+
end
|
17
|
+
|
18
|
+
def shortcut_slot_opts
|
19
|
+
opts = {}
|
20
|
+
opts[:size] = params[:size].to_sym if params[:size]
|
21
|
+
opts[:items] = { view: params[:item].to_sym } if slot_items_shortcut?
|
22
|
+
opts
|
23
|
+
end
|
24
|
+
|
25
|
+
def slot_items_shortcut?
|
26
|
+
params[:item].present? && !params.dig(:slot, :items, :view).present?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/card/format/error.rb
CHANGED
@@ -53,15 +53,20 @@ class Card
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def loud_error e, view
|
56
|
+
log_error e if focal? && voo.root?
|
56
57
|
card.errors.add "#{view} view", rendering_error(e, view) if card.errors.empty?
|
57
58
|
raise e
|
58
59
|
end
|
59
60
|
|
60
61
|
def quiet_error e, view
|
61
62
|
# TODO: unify with Card::Error#report
|
63
|
+
log_error e
|
64
|
+
rendering_error e, view
|
65
|
+
end
|
66
|
+
|
67
|
+
def log_error e
|
62
68
|
Rails.logger.info e.message
|
63
69
|
Rails.logger.debug e.backtrace.join("\n")
|
64
|
-
rendering_error e, view
|
65
70
|
end
|
66
71
|
|
67
72
|
def rendering_error exception, view
|
@@ -38,7 +38,11 @@ class Card
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def preamble_bits
|
41
|
-
[module_comment,
|
41
|
+
[module_comment,
|
42
|
+
module_chain,
|
43
|
+
"extend Card::Set::Pattern::Helper",
|
44
|
+
"cattr_accessor :options",
|
45
|
+
"class << self"]
|
42
46
|
end
|
43
47
|
|
44
48
|
def postamble
|
@@ -70,10 +70,14 @@ class Card
|
|
70
70
|
# The derived codename is all lower case with underscores; "*" and ":" are removed
|
71
71
|
def ensure_code_card name_or_args, content_or_args=nil
|
72
72
|
name, args = standardize_ensure_args name_or_args, content_or_args
|
73
|
-
args[:codename] = name
|
73
|
+
args[:codename] = codename_from_name(name) unless args[:codename]
|
74
74
|
ensure_card_simplified name, args
|
75
75
|
end
|
76
76
|
|
77
|
+
def codename_from_name name
|
78
|
+
name.downcase.tr(" ", "_").tr(":*", "")
|
79
|
+
end
|
80
|
+
|
77
81
|
# create if card doesn't exist
|
78
82
|
# updates existing card only if given attributes are different including
|
79
83
|
# the name
|
@@ -1,14 +1,27 @@
|
|
1
1
|
require "application_job"
|
2
2
|
|
3
3
|
class Card
|
4
|
+
# attributes that ActiveJob can handle
|
5
|
+
def serializable_attributes
|
6
|
+
self.class.action_specific_attributes + set_specific.keys
|
7
|
+
end
|
8
|
+
|
4
9
|
module Set
|
5
10
|
class Event
|
6
11
|
module DelayedEvent
|
7
12
|
DELAY_STAGES = ::Set.new(%i[integrate_with_delay_stage
|
8
13
|
integrate_with_delay_final_stage]).freeze
|
9
14
|
|
15
|
+
def priority
|
16
|
+
@priority || 10
|
17
|
+
end
|
18
|
+
|
10
19
|
private
|
11
20
|
|
21
|
+
def process_delayed_job_opts opts
|
22
|
+
@priority = opts.delete :priority
|
23
|
+
end
|
24
|
+
|
12
25
|
def with_delay? opts
|
13
26
|
DELAY_STAGES.include?(opts[:after]) || DELAY_STAGES.include?(opts[:before])
|
14
27
|
end
|
@@ -27,25 +40,37 @@ class Card
|
|
27
40
|
def define_event_delaying_method
|
28
41
|
@set_module.class_exec(self) do |event|
|
29
42
|
define_method(event.delaying_method_name, proc do
|
30
|
-
IntegrateWithDelayJob
|
31
|
-
|
32
|
-
|
33
|
-
event.simple_method_name
|
34
|
-
)
|
43
|
+
IntegrateWithDelayJob
|
44
|
+
.set(set_delayed_job_args(event))
|
45
|
+
.perform_later(*perform_delayed_job_args(event))
|
35
46
|
end)
|
36
47
|
end
|
37
48
|
end
|
38
49
|
|
39
50
|
class IntegrateWithDelayJob < ApplicationJob
|
40
51
|
def perform act_id, card, card_attribs, env, auth, method_name
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
52
|
+
handle_perform do
|
53
|
+
load_card card, card_attribs
|
54
|
+
ActManager.contextualize_delayed_event act_id, card, env, auth do
|
55
|
+
card.send method_name
|
56
|
+
end
|
45
57
|
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def handle_perform
|
61
|
+
yield
|
62
|
+
rescue StandardError => error
|
63
|
+
Card::Error.report error, @card
|
64
|
+
raise error
|
46
65
|
ensure
|
47
66
|
ActManager.expire
|
48
67
|
end
|
68
|
+
|
69
|
+
def load_card card, card_attribs
|
70
|
+
@card = card
|
71
|
+
Card::Cache.renew
|
72
|
+
card.deserialize_for_active_job! card_attribs
|
73
|
+
end
|
49
74
|
end
|
50
75
|
end
|
51
76
|
end
|
@@ -58,6 +83,21 @@ class Card
|
|
58
83
|
include_set_modules
|
59
84
|
end
|
60
85
|
|
86
|
+
private
|
87
|
+
|
88
|
+
def set_delayed_job_args event
|
89
|
+
{ queue: event.name, priority: event.priority }
|
90
|
+
end
|
91
|
+
|
92
|
+
def perform_delayed_job_args event
|
93
|
+
[Card::ActManager.act&.id,
|
94
|
+
self,
|
95
|
+
serialize_for_active_job,
|
96
|
+
Card::Env.serialize,
|
97
|
+
Card::Auth.serialize,
|
98
|
+
event.simple_method_name]
|
99
|
+
end
|
100
|
+
|
61
101
|
def serialize_for_active_job
|
62
102
|
serializable_attributes.each_with_object({}) do |name, hash|
|
63
103
|
hash[name] = instance_variable_get("@#{name}")
|