Class: Card::Action
- Inherits:
-
Cardio::Record
- Object
- ActiveRecord::Base
- Cardio::Record
- Card::Action
- Extended by:
- Admin
- Defined in:
- mod/history/lib/card/action.rb,
mod/history/lib/card/action/admin.rb,
mod/history/lib/card/action/differ.rb,
mod/history/lib/card/action/changes.rb,
mod/history/lib/card/action/action_renderer.rb
Overview
An action is a group of changes to a single card that is recorded during an act. Together, acts, actions, and changes comprise a comprehensive card history tracking system.
For example, if a given web submission changes both the name and type of a given card, that would be recorded as one action with two changes. If there are multiple cards changed, each card would have its own action, but the whole submission would still comprise just one single act.
An Action records:
Defined Under Namespace
Modules: Admin, Changes, Differ Classes: ActionRenderer
Constant Summary collapse
- TYPE_OPTIONS =
these are the three possible values for action_type
%i[create update delete].freeze
Class Method Summary collapse
-
.all_viewable ⇒ Object
-
.all_with_cards ⇒ Object
-
.cache ⇒ Card::Cache
cache object for actions.
-
.fetch(id) ⇒ Action?
retrieve action from cache if available.
Instance Method Summary collapse
-
#action_type ⇒ Symbol
retrieve action_type (create, update, or delete).
-
#action_type=(value) ⇒ Integer
assign action_type (create, update, or delete).
-
#card ⇒ Card
each action is associated with on and only one card.
-
#card_id ⇒ Object
sometimes Object#card_id interferes with default ActiveRecord attribute def.
-
#expire ⇒ Object
remove action from action cache.
-
#previous_action ⇒ Object
-
#sole? ⇒ Boolean
Methods included from Admin
delete_cardless, delete_old, make_current_state_the_initial_state
Methods included from Changes
#all_changes, #change, #changed_values, #changes, #current_changes, #previous_change, #previous_value, #value
Methods included from Differ
#cardtype_diff, #content_diff, #new_content?, #new_name?, #new_type?, #raw_view, #summary_diff_omits_content?
Class Method Details
.all_viewable ⇒ Object
66 67 68 |
# File 'mod/history/lib/card/action.rb', line 66 def all_viewable all_with_cards.where Query::CardQuery.viewable_sql end |
.all_with_cards ⇒ Object
62 63 64 |
# File 'mod/history/lib/card/action.rb', line 62 def all_with_cards joins :ar_card end |
.cache ⇒ Card::Cache
cache object for actions
58 59 60 |
# File 'mod/history/lib/card/action.rb', line 58 def cache Card::Cache[Action] end |
.fetch(id) ⇒ Action?
retrieve action from cache if available
50 51 52 53 54 |
# File 'mod/history/lib/card/action.rb', line 50 def fetch id cache.fetch id.to_s do where(id: id.to_i).take end end |
Instance Method Details
#action_type ⇒ Symbol
retrieve action_type (create, update, or delete)
96 97 98 99 100 |
# File 'mod/history/lib/card/action.rb', line 96 def action_type return :draft if draft TYPE_OPTIONS[read_attribute(:action_type)] end |
#action_type=(value) ⇒ Integer
assign action_type (create, update, or delete)
90 91 92 |
# File 'mod/history/lib/card/action.rb', line 90 def action_type= value write_attribute :action_type, TYPE_OPTIONS.index(value) end |
#card ⇒ Card
each action is associated with on and only one card
78 79 80 |
# File 'mod/history/lib/card/action.rb', line 78 def card Card.fetch card_id, look_in_trash: true end |
#card_id ⇒ Object
sometimes Object#card_id interferes with default ActiveRecord attribute def
72 73 74 |
# File 'mod/history/lib/card/action.rb', line 72 def card_id _read_attribute "card_id" end |
#expire ⇒ Object
remove action from action cache
83 84 85 |
# File 'mod/history/lib/card/action.rb', line 83 def expire self.class.cache.delete id.to_s end |