Module: Card::Set::All::History::Last
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod005-history/all/history/last.rb
Overview
Set: All cards (History, Last)
Constant Summary
Constants included
from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Card::Set
reset_modules
Methods included from I18nScope
#mod_name, #scope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set
Methods included from Helpers
#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore
#attachment, #ensure_set, #stage_method
Methods included from Format
#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket, #unshift_basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
#event
Class Method Details
.source_location ⇒ Object
7
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 7
def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/history/set/all/history/last.rb"; end
|
Instance Method Details
#acted_at ⇒ Object
8
9
10
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 8
def acted_at
last_act.acted_at
end
|
#create_action_last_change?(action_id) ⇒ Boolean
34
35
36
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 34
def create_action_last_change? action_id
action_id == create_action.id || (!action_id && create_action.sole?)
end
|
#last_act ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 76
def last_act
@last_act ||=
if (action = last_action)
last_act_on_self = acts.last
act_of_last_action = action.act
return act_of_last_action unless last_act_on_self
return last_act_on_self unless act_of_last_action
return last_act_on_self if act_of_last_action == last_act_on_self
if last_act_on_self.acted_at > act_of_last_action.acted_at
last_act_on_self
else
act_of_last_action
end
end
end
|
#last_action ⇒ Object
60
61
62
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 60
def last_action
actions.where("id IS NOT NULL").last
end
|
#last_action_id ⇒ Object
56
57
58
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 56
def last_action_id
last_action&.id
end
|
#last_actor ⇒ Object
72
73
74
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 72
def last_actor
last_act.actor
end
|
#last_change_from_action_id(action_id, field, opts) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 38
def last_change_from_action_id action_id, field, opts
Change.joins(:action).where(
last_change_sql_conditions(opts),
card_id: id,
action_id: action_id,
field: Card::Change.field_index(field)
).order(:id).last
end
|
#last_change_on(field, opts = {}) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 16
def last_change_on field, opts={}
action_id = (opts[:before] || opts[:not_after])
if no_last_change? action_id, opts[:before]
nil
elsif create_action_last_change? action_id
create_action.change field
else
last_change_from_action_id action_id, field, opts
end
end
|
#last_change_sql_conditions(opts) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 47
def last_change_sql_conditions opts
cond = "card_actions.card_id = :card_id AND field = :field"
cond += " AND (draft is not true)" unless opts[:including_drafts]
operator = "<" if opts[:before]
operator = "<=" if opts[:not_after]
cond += " AND card_action_id #{operator} :action_id" if operator
cond
end
|
#last_content_action ⇒ Object
64
65
66
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 64
def last_content_action
last_change_on(:db_content)&.action
end
|
#last_content_action_id ⇒ Object
68
69
70
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 68
def last_content_action_id
last_change_on(:db_content)&.card_action_id
end
|
#no_last_change?(action_id, before) ⇒ Boolean
30
31
32
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 30
def no_last_change? action_id, before
before && action_id == create_action.id
end
|
#previous_action(action_id) ⇒ Object
94
95
96
97
98
99
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 94
def previous_action action_id
return unless action_id
action_index = actions.find_index { |a| a.id == action_id }
all_actions[action_index - 1] if action_index.to_i.nonzero?
end
|
#revised_at ⇒ Object
12
13
14
|
# File 'tmpsets/set/mod005-history/all/history/last.rb', line 12
def revised_at
(last_action && (act = last_action.act) && act.acted_at) || Time.zone.now
end
|