Class: Card::ActManager
- Inherits:
-
Object
show all
- Extended by:
- EventDelay
- Defined in:
- lib/card/act_manager.rb,
lib/card/act_manager/stage.rb,
lib/card/act_manager/event_delay.rb,
lib/card/act_manager/stage_director.rb,
lib/card/act_manager/subdirector_array.rb,
lib/card/act_manager/stage_director/phases.rb
Overview
available values:
dirty attributes yes | yes | yes
params yes | yes | yes
success yes | yes | yes no
session yes | yes | yes no
Explanation:
yes! the recommended stage to do that
yes ok to do it here
no not recommended; chance to mess things up
but if something forces you to do it here you can try
no! never do it here. it won't work or will break things
if there is only a single entry in a phase column it counts for all stages
of that phase
1) 'insecure' means a change of a card attribute that can possibly make
the card invalid to save
2) 'secure' means you are sure that the change doesn't affect the validation
3) In all stages except IGwD:
If you call 'create', 'update' or 'save' the card will become
part of the same act and all stage of the validation and storage phase
will be executed immediately for that card. The integration phase will be
executed together with the act card and its subcards.
In IGwD all these methods create a new act.
4) This means if an exception is raised in the validation or storage phase
everything will rollback. If the integration phase fails the db changes
of the other two phases will remain persistent.
Defined Under Namespace
Modules: EventDelay, Stage
Classes: StageDirector, StageSubdirector, SubdirectorArray
Class Attribute Summary collapse
Class Method Summary
collapse
Methods included from EventDelay
contextualize_delayed_event, contextualize_for_delay, delaying?, run_job_with_act, with_env_and_auth
Class Attribute Details
.act ⇒ Object
Returns the value of attribute act.
80
81
82
|
# File 'lib/card/act_manager.rb', line 80
def act
@act
end
|
.act_card ⇒ Object
Returns the value of attribute act_card.
80
81
82
|
# File 'lib/card/act_manager.rb', line 80
def act_card
@act_card
end
|
Class Method Details
.act_director ⇒ Object
82
83
84
85
86
|
# File 'lib/card/act_manager.rb', line 82
def act_director
return unless act_card
act_card.director
end
|
.add(director) ⇒ Object
155
156
157
158
|
# File 'lib/card/act_manager.rb', line 155
def add director
directors[director.card] = director
end
|
.card(name) ⇒ Object
149
150
151
152
153
|
# File 'lib/card/act_manager.rb', line 149
def card name
directors.values.find do |dir|
dir.card.name == name
end&.card
end
|
.card_changed(old_card) ⇒ Object
160
161
162
163
164
|
# File 'lib/card/act_manager.rb', line 160
def card_changed old_card
return unless (director = @directors.delete old_card)
add director
end
|
.clear ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/card/act_manager.rb', line 104
def clear
self.act_card = nil
self.act = nil
directors.each_pair do |card, _dir|
card.expire
card.director = nil
card.clear_action_specific_attributes
end
expire
@directors = nil
end
|
.deep_delete(director) ⇒ Object
173
174
175
176
177
178
|
# File 'lib/card/act_manager.rb', line 173
def deep_delete director
director.subdirectors.each do |subdir|
deep_delete subdir
end
delete director
end
|
.delete(director) ⇒ Object
166
167
168
169
170
171
|
# File 'lib/card/act_manager.rb', line 166
def delete director
return unless @directors
@directors.delete director.card
director.delete
end
|
.directors ⇒ Object
88
89
90
|
# File 'lib/card/act_manager.rb', line 88
def directors
@directors ||= {}
end
|
.expire ⇒ Object
116
117
118
119
|
# File 'lib/card/act_manager.rb', line 116
def expire
expirees.each { |expiree| Card.expire expiree }
@expirees = []
end
|
.expirees ⇒ Object
121
122
123
|
# File 'lib/card/act_manager.rb', line 121
def expirees
@expirees ||= []
end
|
.fetch(card, opts = {}) ⇒ Object
FIXME: use "parent" instead of opts (it's the only option)
126
127
128
129
130
131
132
133
|
# File 'lib/card/act_manager.rb', line 126
def fetch card, opts={}
return directors[card] if directors[card]
directors.each_key do |dir_card|
return dir_card.director if dir_card.name == card.name && dir_card.director
end
add new_director(card, opts)
end
|
.include?(name) ⇒ Boolean
135
136
137
|
# File 'lib/card/act_manager.rb', line 135
def include? name
directors.keys.any? { |card| card.key == name.to_name.key }
end
|
.need_act ⇒ Object
100
101
102
|
# File 'lib/card/act_manager.rb', line 100
def need_act
self.act ||= Card::Act.create ip_address: Env.ip
end
|
.new_director(card, opts = {}) ⇒ Object
139
140
141
142
143
144
145
146
147
|
# File 'lib/card/act_manager.rb', line 139
def new_director card, opts={}
if opts[:parent]
StageSubdirector.new card, opts
elsif act_card && act_card != card && running_act?
act_card.director.subdirectors.add card
else
StageDirector.new card
end
end
|
.run_act(card) ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/card/act_manager.rb', line 92
def run_act card
self.act_card = card
yield
ensure
clear
end
|
.running_act? ⇒ Boolean
180
181
182
|
# File 'lib/card/act_manager.rb', line 180
def running_act?
act_director&.running?
end
|
.to_s ⇒ Object
184
185
186
|
# File 'lib/card/act_manager.rb', line 184
def to_s
act_director.to_s
end
|