Module: Card::Action::Admin
- Included in:
- Card::Action
- Defined in:
- lib/card/action/admin.rb
Overview
methods for administering card actions
Instance Method Summary collapse
- #delete_cardless ⇒ Object
- #delete_old ⇒ Object
-
#make_current_state_the_initial_state(act = nil) ⇒ Object
If an act is given then all remaining actions will be attached to that act.
Instance Method Details
#delete_cardless ⇒ Object
6 7 8 9 |
# File 'lib/card/action/admin.rb', line 6 def delete_cardless left_join = "LEFT JOIN cards ON card_actions.card_id = cards.id" joins(left_join).where("cards.id IS NULL").delete_all end |
#delete_old ⇒ Object
13 14 15 16 17 |
# File 'lib/card/action/admin.rb', line 13 def delete_old Card::Change.delete_all Card.find_each(&:delete_old_actions) Card::Act.delete_actionless end |
#make_current_state_the_initial_state(act = nil) ⇒ Object
If an act is given then all remaining actions will be attached to that act. Otherwise the actions keep their acts.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/card/action/admin.rb', line 21 def make_current_state_the_initial_state act=nil Card::Change.delete_all Card.find_each(&:delete_old_actions) action_update = { action_type: Card::Action::TYPE_OPTIONS.index(:create) } action_update[:card_act_id] = act.id if act Card::Action.update_all action_update if act Card::Act.where("id != :id", id: act.id).delete_all else Card::Act.delete_actionless end end |