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

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod015-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

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

Methods included from Card::Set::AdvancedApi

#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

Methods included from Inheritance

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



9
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 9

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

Instance Method Details

#contentObject

the base methods.



11
12
13
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 11

def content
  @selected_action_id ? selected_content : super
end

#content=(value) ⇒ Object



15
16
17
18
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 15

def content= value
  @selected_content = nil
  super
end

#content_at_time_of_selected_actionObject



48
49
50
51
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 48

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

#select_action(action_id) ⇒ Object



25
26
27
28
29
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 25

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
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 20

def select_action_by_params params
  action = nth_action(params[:rev]) || action_from_id(params[:rev_id])
  select_action action.id if action
end

#select_action_id(action_id) ⇒ Object



61
62
63
64
65
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 61

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

#selected_actionObject



40
41
42
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 40

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

#selected_action_idObject



31
32
33
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 31

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

#selected_action_id=(action_id) ⇒ Object



35
36
37
38
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 35

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

#selected_contentObject



44
45
46
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 44

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

#selected_content_action_idObject



67
68
69
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 67

def selected_content_action_id
  @selected_action_id || new_content_action_id || last_content_action_id
end

#with_selected_action_id(action_id) ⇒ Object



53
54
55
56
57
58
59
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/selected.rb', line 53

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