Module: Card::Set::All::History::Revision
- Extended by:
- Card::Set
- Defined in:
- platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb
Overview
Set: All cards (History, Revision)
Constant Summary
Constants included
from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Constants included
from Event::Api
Event::Api::OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Card::Set
reset
Methods included from I18nScope
#mod_name, #scope
Methods included from Registrar
#extended, #finalize_load, #process_base_modules, #register_set
Methods included from Helpers
#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name
#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #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 Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
#event
Class Method Details
.source_location ⇒ Object
7
|
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb', line 7
def self.source_location; "/Users/ethan/dev/decko/gem/mod/history/set/all/history/revision.rb"; end
|
Instance Method Details
#actions_to_revert ⇒ Object
50
51
52
53
54
55
56
|
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb', line 50
def actions_to_revert
if (act_id = Env.params["revert_act"])
Act.find(act_id).actions
else
explicit_actions_to_revert
end
end
|
#explicit_actions_to_revert ⇒ Object
58
59
60
61
62
|
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb', line 58
def explicit_actions_to_revert
Array.wrap(Env.params["revert_actions"]).map do |a_id|
Action.fetch(a_id) || nil
end.compact
end
|
#merge_revert_action!(action, update_args, reverting_to_previous) ⇒ Object
64
65
66
67
68
69
70
71
72
|
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb', line 64
def merge_revert_action! action, update_args, reverting_to_previous
rev = action.card.revision(action, reverting_to_previous)
rev.delete :name unless rev[:name] if action.card_id == id
update_args.merge! rev
else
update_args[:subcards][action.card.name] = rev
end
end
|
#process_revert_actions(revert_actions = nil) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb', line 40
def process_revert_actions revert_actions=nil
revert_actions ||= actions_to_revert
update_args = { subcards: {} }
reverting_to_previous = Env.params["revert_to"] == "previous"
revert_actions.each do |action|
merge_revert_action! action, update_args, reverting_to_previous
end
update_args
end
|
#revision(action, before_action = false) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb', line 8
def revision action, before_action=false
action = Card::Action.fetch(action) if action.is_a? Integer
return unless action
if before_action
revision_before_action action
else
revision_attributes action
end
end
|
#revision_attributes(action) ⇒ Object
21
22
23
24
25
26
|
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb', line 21
def revision_attributes action
Card::Change::TRACKED_FIELDS.each_with_object({}) do |field, attr_changes|
last_change = action.change(field) || last_change_on(field, not_after: action)
attr_changes[field.to_sym] = (last_change ? last_change.value : self[field])
end
end
|
#revision_before_action(action) ⇒ Object
28
29
30
31
32
33
34
|
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb', line 28
def revision_before_action action
if (prev_action = action.previous_action)
revision prev_action
else
{ trash: true }
end
end
|
#rollback_request? ⇒ Boolean
36
37
38
|
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/revision.rb', line 36
def rollback_request?
history? && actions_to_revert.any?
end
|