Module: Pageflow::Translatable Private

Extended by:
ActiveSupport::Concern
Included in:
Entry
Defined in:
app/models/concerns/pageflow/translatable.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#default_translation?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


49
50
51
# File 'app/models/concerns/pageflow/translatable.rb', line 49

def default_translation?
  translation_group&.default_translation == self
end

#mark_as_default_translationObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
# File 'app/models/concerns/pageflow/translatable.rb', line 45

def mark_as_default_translation
  translation_group.update!(default_translation: self)
end

#mark_as_translation_of(entry) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/concerns/pageflow/translatable.rb', line 24

def mark_as_translation_of(entry)
  transaction do
    ensure_translation_group(entry)

    if !entry.translation_group
      entry.update!(translation_group:)
    elsif entry.translation_group != translation_group
      entry.translation_group.merge_into(translation_group)
    end
  end
end

#remove_from_translation_groupObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
39
40
41
42
43
# File 'app/models/concerns/pageflow/translatable.rb', line 36

def remove_from_translation_group
  if translation_group.entries.count <= 2
    translation_group.destroy
  else
    translation_group.update(default_translation: nil) if default_translation?
    update!(translation_group: nil)
  end
end