Module: Alchemy::ConfigurationMethods

Extended by:
ActiveSupport::Concern
Included in:
BaseController
Defined in:
lib/alchemy/configuration_methods.rb

Instance Method Summary collapse

Instance Method Details

#configuration(name) ⇒ Object

Deprecated.
  • Use Alchemy.config.get instead

Returns the configuration value of given key.

Config file is in config/alchemy/config.yml



16
17
18
# File 'lib/alchemy/configuration_methods.rb', line 16

def configuration(name)
  Alchemy.config.get(name)
end

#multi_language?Boolean

Returns true if more than one language is published on current site.

Returns:

  • (Boolean)


23
24
25
# File 'lib/alchemy/configuration_methods.rb', line 23

def multi_language?
  Language.on_current_site.published.count > 1
end

#multi_site?Boolean

Returns true if more than one site exists.

Returns:

  • (Boolean)


41
42
43
# File 'lib/alchemy/configuration_methods.rb', line 41

def multi_site?
  Site.count > 1
end

#prefix_locale?(locale = Current.language&.code) ⇒ Boolean

Decides if the locale should be prefixed to urls

If the current language’s locale (or the optionally passed in locale) matches the current I18n.locale then the prefix os omitted. Also, if only one published language exists.

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/alchemy/configuration_methods.rb', line 33

def prefix_locale?(locale = Current.language&.code)
  return false unless locale

  multi_language? && locale != ::I18n.default_locale.to_s
end