Module: Card::Director::ClassMethods
Overview
Card::Director class methods
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from EventDelay
#contextualize_delayed_event, #delaying?, #run_job_with_act, #with_delay_act, #with_env_and_auth
Instance Attribute Details
#act ⇒ Object
Returns the value of attribute act.
7
8
9
|
# File 'lib/card/director/class_methods.rb', line 7
def act
@act
end
|
#act_card ⇒ Object
Returns the value of attribute act_card.
7
8
9
|
# File 'lib/card/director/class_methods.rb', line 7
def act_card
@act_card
end
|
Instance Method Details
#act_director ⇒ Object
9
10
11
|
# File 'lib/card/director/class_methods.rb', line 9
def act_director
act_card&.director
end
|
#add(director) ⇒ Object
75
76
77
78
|
# File 'lib/card/director/class_methods.rb', line 75
def add director
directors[director.card] = director
end
|
#card(name) ⇒ Object
69
70
71
72
73
|
# File 'lib/card/director/class_methods.rb', line 69
def card name
directors.values.find do |dir|
dir.card.name == name
end&.card
end
|
#card_changed(old_card) ⇒ Object
80
81
82
83
84
|
# File 'lib/card/director/class_methods.rb', line 80
def card_changed old_card
return unless (director = @directors.delete old_card)
add director
end
|
#clear ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/card/director/class_methods.rb', line 31
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
94
95
96
97
98
99
|
# File 'lib/card/director/class_methods.rb', line 94
def deep_delete director
director.subdirectors.each do |subdir|
deep_delete subdir
end
delete director
end
|
#delete(director) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/card/director/class_methods.rb', line 86
def delete director
return unless @directors
@directors.delete_if { |k, _v| k == director.card }
director.delete
end
|
#directors ⇒ Object
13
14
15
|
# File 'lib/card/director/class_methods.rb', line 13
def directors
@directors ||= {}
end
|
#expire ⇒ Object
43
44
45
46
|
# File 'lib/card/director/class_methods.rb', line 43
def expire
expirees.each { |expiree| Card.expire expiree }
@expirees = []
end
|
#expirees ⇒ Object
48
49
50
|
# File 'lib/card/director/class_methods.rb', line 48
def expirees
@expirees ||= []
end
|
#fetch(card, parent = nil) ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/card/director/class_methods.rb', line 52
def fetch card, parent=nil
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, parent)
end
|
#include?(name) ⇒ Boolean
61
62
63
|
# File 'lib/card/director/class_methods.rb', line 61
def include? name
directors.keys.any? { |card| card.key == name.to_name.key }
end
|
#include_id?(id) ⇒ Boolean
65
66
67
|
# File 'lib/card/director/class_methods.rb', line 65
def include_id? id
directors.keys.any? { |card| card.id == id }
end
|
#need_act ⇒ Object
27
28
29
|
# File 'lib/card/director/class_methods.rb', line 27
def need_act
self.act ||= Card::Act.new ip_address: Env.ip
end
|
#run_act(card) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/card/director/class_methods.rb', line 17
def run_act card
Lexicon.rescuing do
self.act_card = card
yield
end
ensure
clear
end
|
#to_s ⇒ Object
101
102
103
|
# File 'lib/card/director/class_methods.rb', line 101
def to_s
act_director.to_s
end
|