Module: Card::Set::All::History::Actions

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

Overview

Set: All cards (History, Actions)

-- encoding : utf-8 --

Defined Under Namespace

Modules: HtmlFormat

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



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

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

Instance Method Details

#action_from_id(action_id) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 14

def action_from_id action_id
  return unless action_id.is_a?(Integer) || action_id =~ /^\d+$/

  # if not an integer revision id is probably a mod (e.g. if you request
  # files/:logo/standard.png)
  action = Action.fetch action_id
  return unless action.card_id == id

  action
end

#action_if_on_self(action) ⇒ Object



23
24
25
26
27
# File 'card/tmpsets/set/mod012-card-mod-history/all/history/actions.rb', line 23

def action_if_on_self action
  return unless action.is_a? Action

  action if action.card_id == id
end

#all_action_idsObject



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

def all_action_ids
  Card::Action.where(card_id: id).pluck :id
end

#create_actionObject



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

def create_action
  @create_action ||= actions.first
end

#current_action_changes_content?Boolean

Returns:

  • (Boolean)


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

def current_action_changes_content?
  new_card? || @current_action.new_content? || db_content_is_changing?
end

#new_content_action_idObject



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

def new_content_action_id
  return unless @current_action && current_action_changes_content?

  @current_action.id
end

#nth_action(index) ⇒ Object



33
34
35
36
37
38
39
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 33

def nth_action index
  index = index.to_i
  return unless id && index.positive?

  Action.where("draft is not true AND card_id = #{id}")
        .order(:id).limit(1).offset(index - 1).first
end

#old_actionsObject



25
26
27
# File 'card/tmpsets/set/mod013-card-mod-history/all/history/actions.rb', line 25

def old_actions
  actions.where("id != ?", last_action_id)
end