Module: Card::Director::CardMethods

Included in:
Card
Defined in:
card/lib/card/director/card_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#directorObject



9
10
11
# File 'card/lib/card/director/card_methods.rb', line 9

def director
  @director ||= Director.fetch self
end

Instance Method Details

#clear_action_specific_attributesObject



39
40
41
42
43
# File 'card/lib/card/director/card_methods.rb', line 39

def clear_action_specific_attributes
  self.class.action_specific_attributes.each do |attr|
    instance_variable_set "@#{attr}", nil
  end
end

#identify_actionObject



19
20
21
22
23
24
25
26
27
28
# File 'card/lib/card/director/card_methods.rb', line 19

def identify_action
  @action =
    if trash && trash_changed?
      :delete
    elsif new_card?
      :create
    else
      :update
    end
end

#prepare_for_phasesObject



13
14
15
16
17
# File 'card/lib/card/director/card_methods.rb', line 13

def prepare_for_phases
  reset_patterns
  identify_action
  include_set_modules
end

#restore_changes_informationObject



30
31
32
33
34
35
36
37
# File 'card/lib/card/director/card_methods.rb', line 30

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