Class: Spina::Pages::TranslationsComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Spina::Pages::TranslationsComponent
- Defined in:
- app/components/spina/pages/translations_component.rb
Instance Method Summary collapse
- #existing_locales ⇒ Object
-
#initialize(page, label: nil) ⇒ TranslationsComponent
constructor
A new instance of TranslationsComponent.
- #missing_locales ⇒ Object
- #render? ⇒ Boolean
Constructor Details
#initialize(page, label: nil) ⇒ TranslationsComponent
Returns a new instance of TranslationsComponent.
4 5 6 7 |
# File 'app/components/spina/pages/translations_component.rb', line 4 def initialize(page, label: nil) @page = page @label = label end |
Instance Method Details
#existing_locales ⇒ Object
17 18 19 20 21 |
# File 'app/components/spina/pages/translations_component.rb', line 17 def existing_locales @existing_locales ||= @page.translations.pluck(:locale).map(&:to_sym).sort_by do |locale| spina_locales.index(locale) end end |
#missing_locales ⇒ Object
13 14 15 |
# File 'app/components/spina/pages/translations_component.rb', line 13 def missing_locales spina_locales - existing_locales end |
#render? ⇒ Boolean
9 10 11 |
# File 'app/components/spina/pages/translations_component.rb', line 9 def render? spina_locales.many? end |