Class: Alchemy::Admin::LocaleSelect

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/alchemy/admin/locale_select.rb

Overview

Renders a locale select tag for switching the backend locale.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :change_locale) ⇒ LocaleSelect

Returns a new instance of LocaleSelect.



7
8
9
# File 'app/components/alchemy/admin/locale_select.rb', line 7

def initialize(name = :change_locale)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'app/components/alchemy/admin/locale_select.rb', line 5

def name
  @name
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
# File 'app/components/alchemy/admin/locale_select.rb', line 11

def call
  select_tag(
    name,
    options_for_select(
      translations_for_select,
      ::I18n.locale
    )
  )
end

#render?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/components/alchemy/admin/locale_select.rb', line 21

def render?
  available_locales.many?
end