Sha256: 603e47724b32b073eddcca7447c2abd86a7742cf7bb09a5933ac700c418ae92b

Contents?: true

Size: 1.46 KB

Versions: 19

Compression:

Stored size: 1.46 KB

Contents

# 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
# the base methods.
def content
  @selected_action_id ? selected_content : super
end

def content= value
  @selected_content = nil
  super
end

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

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

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

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

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

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

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

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

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

def selected_content_action_id
  @selected_action_id || new_content_action_id || last_content_action_id
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
card-mod-history-0.11.4 set/all/history/selected.rb
card-mod-history-0.11.3 set/all/history/selected.rb
card-mod-history-0.11.2 set/all/history/selected.rb
card-mod-history-0.11.1 set/all/history/selected.rb
card-mod-history-0.11.0 set/all/history/selected.rb
card-1.100.0 mod/history/set/all/history/selected.rb
card-1.99.6 mod/history/set/all/history/selected.rb
card-1.99.5 mod/history/set/all/history/selected.rb
card-1.99.4 mod/history/set/all/history/selected.rb
card-1.99.3 mod/history/set/all/history/selected.rb
card-1.99.2 mod/history/set/all/history/selected.rb
card-1.99.1 mod/history/set/all/history/selected.rb
card-1.99.0 mod/history/set/all/history/selected.rb
card-1.98.3 mod/history/set/all/history/selected.rb
card-1.98.2 mod/history/set/all/history/selected.rb
card-1.98.1 mod/history/set/all/history/selected.rb
card-1.98.0 mod/history/set/all/history/selected.rb
card-1.97.0.1 mod/history/set/all/history/selected.rb
card-1.97.0 mod/history/set/all/history/selected.rb