Module: Card::Director::All
- Included in:
- Card
- Defined in:
- card/lib/card/director/all.rb
Overview
director-related Card instance methods
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#act(options = {}, &block) ⇒ Object
-
#act_card ⇒ Object
-
#act_card? ⇒ Boolean
-
#clear_action_specific_attributes ⇒ Object
-
#identify_action ⇒ Object
-
#prepare_for_phases ⇒ Object
-
#restore_changes_information ⇒ Object
-
#save(*_args) ⇒ Object
-
#save!(**args) ⇒ Object
-
#save_if_needed ⇒ Object
-
#save_if_needed! ⇒ Object
-
#save_needed? ⇒ Boolean
-
#update(*_args) ⇒ Object
(also: #update_attributes)
-
#update!(*_args) ⇒ Object
(also: #update_attributes!)
-
#valid?(*_args) ⇒ Boolean
Instance Attribute Details
Instance Method Details
#act(options = {}, &block) ⇒ Object
30 31 32 33 34 35 36 |
# File 'card/lib/card/director/all.rb', line 30 def act ={}, &block if act_card add_to_act , &block else start_new_act(&block) end end |
#act_card ⇒ Object
38 39 40 |
# File 'card/lib/card/director/all.rb', line 38 def act_card Card::Director.act_card end |
#act_card? ⇒ Boolean
42 43 44 |
# File 'card/lib/card/director/all.rb', line 42 def act_card? self == act_card end |
#clear_action_specific_attributes ⇒ Object
98 99 100 101 102 |
# File 'card/lib/card/director/all.rb', line 98 def clear_action_specific_attributes self.class.action_specific_attributes.each do |attr| instance_variable_set "@#{attr}", nil end end |
#identify_action ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'card/lib/card/director/all.rb', line 19 def identify_action @action = if trash && trash_changed? :delete elsif new_card? :create else :update end end |
#prepare_for_phases ⇒ Object
14 15 16 17 |
# File 'card/lib/card/director/all.rb', line 14 def prepare_for_phases reset_patterns include_set_modules end |
#restore_changes_information ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'card/lib/card/director/all.rb', line 89 def restore_changes_information # restores changes for integration phase # (rails cleared them in an after_create/after_update hook which is # executed before the integration phase) return unless saved_changes.present? @mutations_from_database = mutations_before_last_save end |
#save(*_args) ⇒ Object
51 52 53 |
# File 'card/lib/card/director/all.rb', line 51 def save *_args act { super } end |
#save!(**args) ⇒ Object
46 47 48 49 |
# File 'card/lib/card/director/all.rb', line 46 def save! **args as_subcard = args.delete :as_subcard act(as_subcard: as_subcard) { super **args } end |
#save_if_needed ⇒ Object
67 68 69 70 |
# File 'card/lib/card/director/all.rb', line 67 def save_if_needed validate save if save_needed? end |
#save_if_needed! ⇒ Object
72 73 74 75 |
# File 'card/lib/card/director/all.rb', line 72 def save_if_needed! validate save! if save_needed? end |
#save_needed? ⇒ Boolean
77 78 79 80 81 82 83 84 |
# File 'card/lib/card/director/all.rb', line 77 def save_needed? # ( new? || test_field_changing? || subcards.cards.any?(&:save_needed?) # ).tap do |r| # # binding.pry if r # puts "save needed for #{name}".yellow if r && !new? # end end |
#update(*_args) ⇒ Object Also known as: update_attributes
59 60 61 |
# File 'card/lib/card/director/all.rb', line 59 def update *_args act { super } end |
#update!(*_args) ⇒ Object Also known as: update_attributes!
63 64 65 |
# File 'card/lib/card/director/all.rb', line 63 def update! *_args act { super } end |
#valid?(*_args) ⇒ Boolean
55 56 57 |
# File 'card/lib/card/director/all.rb', line 55 def valid? *_args act(validating: true) { super } end |