Module: Card::Set::All::History::Selected

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb,
card/tmpsets/set/mod012-card-mod-history/all/history/selected.rb

Overview

Set: All cards (History, Selected)

if these aren’t in a nested module, the methods just overwrite the base methods, but we need a distinct module so that super will be able to refer to

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_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

Methods included from Card::Set::AdvancedApi

#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

Methods included from Inheritance

#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_locationObject



9
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 9

def self.source_location; "/Users/ethan/dev/decko/gem/card-mod-history/set/all/history/selected.rb"; end

Instance Method Details

#contentObject

the base methods.



11
12
13
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 11

def content
  @selected_action_id ? selected_content : super
end

#content=(value) ⇒ Object



15
16
17
18
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 15

def content= value
  @selected_content = nil
  super
end

#content_at_time_of_selected_actionObject



50
51
52
53
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 50

def content_at_time_of_selected_action
  lc = last_change_on(:db_content, not_after: @selected_action_id, including_drafts: true)
  lc&.value
end

#select_action(action_id) ⇒ Object



27
28
29
30
31
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 27

def select_action action_id
  run_callbacks :select_action do
    self.selected_action_id = action_id
  end
end

#select_action_by_params(params) ⇒ Object



20
21
22
23
24
25
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 20

def select_action_by_params params
  action = nth_action(params[:rev]) || action_from_id(params[:rev_id])
  return unless action

  select_action action.id
end

#select_action_id(action_id) ⇒ Object



63
64
65
66
67
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 63

def select_action_id action_id
  run_callbacks :select_action do
    self.selected_action_id = action_id
  end
end

#selected_actionObject



42
43
44
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 42

def selected_action
  selected_action_id && Action.fetch(selected_action_id)
end

#selected_action_idObject



33
34
35
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 33

def selected_action_id
  @selected_action_id || (@current_action&.id) || last_action_id
end

#selected_action_id=(action_id) ⇒ Object



37
38
39
40
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 37

def selected_action_id= action_id
  @selected_content = nil
  @selected_action_id = action_id
end

#selected_contentObject



46
47
48
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 46

def selected_content
  @selected_content ||= content_at_time_of_selected_action || db_content
end

#selected_content_action_idObject



69
70
71
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 69

def selected_content_action_id
  @selected_action_id || new_content_action_id || last_content_action_id
end

#with_selected_action_id(action_id) ⇒ Object



55
56
57
58
59
60
61
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/selected.rb', line 55

def with_selected_action_id action_id
  current_action_id = @selected_action_id
  select_action_id action_id
  result = yield
  select_action_id current_action_id
  result
end