Module: Card::DirtyNames

Included in:
Card
Defined in:
lib/card/dirty.rb

Overview

Even special-er handling for dirty cardnames

Instance Method Summary collapse

Instance Method Details

#dirty_name(left_id, right_id) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/card/dirty.rb', line 64

def dirty_name left_id, right_id
  return unless left_id.present? && right_id.present?

  parts = [left_id, right_id].map { |id| Card.quick_fetch(id)&.name_before_act }

  Card::Name[*parts]
end

#lex_before_actObject



72
73
74
75
76
77
78
# File 'lib/card/dirty.rb', line 72

def lex_before_act
  if (old_left_id = left_id_before_act)
    [old_left_id, right_id_before_act]
  else
    name_before_act
  end
end

#name_before_actObject

def name_before_last_save

super || dirty_name(left_id_before_last_save, right_id_before_last_save)

end



60
61
62
# File 'lib/card/dirty.rb', line 60

def name_before_act
  super || dirty_name(left_id_before_act, right_id_before_act)
end

#name_is_changing?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/card/dirty.rb', line 52

def name_is_changing?
  super || left_id_is_changing? || right_id_is_changing?
end