Sha256: 5b914cf63b40a3006308e1fdd071aca5646fe4c20c3a72399521311d29c0fcde

Contents?: true

Size: 1.07 KB

Versions: 19

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Alchemy
  module ConfigurationMethods
    extend ActiveSupport::Concern

    included do
      helper_method :configuration, :multi_language?, :multi_site?, :prefix_locale?
    end

    # Returns the configuration value of given key.
    #
    # Config file is in +config/alchemy/config.yml+
    #
    def configuration(name)
      Config.get(name)
    end

    # Returns true if more than one language is published on current site.
    #
    def multi_language?
      Language.on_current_site.published.count > 1
    end

    # 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.
    #
    def prefix_locale?(locale = Current.language&.code)
      return false unless locale

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

    # Returns true if more than one site exists.
    #
    def multi_site?
      Site.count > 1
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
alchemy_cms-7.4.2 lib/alchemy/configuration_methods.rb
alchemy_cms-7.3.6 lib/alchemy/configuration_methods.rb
alchemy_cms-7.2.9 lib/alchemy/configuration_methods.rb
alchemy_cms-7.4.1 lib/alchemy/configuration_methods.rb
alchemy_cms-7.4.0 lib/alchemy/configuration_methods.rb
alchemy_cms-7.3.5 lib/alchemy/configuration_methods.rb
alchemy_cms-7.2.8 lib/alchemy/configuration_methods.rb
alchemy_cms-7.3.4 lib/alchemy/configuration_methods.rb
alchemy_cms-7.3.3 lib/alchemy/configuration_methods.rb
alchemy_cms-7.3.2 lib/alchemy/configuration_methods.rb
alchemy_cms-7.2.7 lib/alchemy/configuration_methods.rb
alchemy_cms-7.3.1 lib/alchemy/configuration_methods.rb
alchemy_cms-7.3.0 lib/alchemy/configuration_methods.rb
alchemy_cms-7.2.6 lib/alchemy/configuration_methods.rb
alchemy_cms-7.2.5 lib/alchemy/configuration_methods.rb
alchemy_cms-7.2.4 lib/alchemy/configuration_methods.rb
alchemy_cms-7.2.3 lib/alchemy/configuration_methods.rb
alchemy_cms-7.2.2 lib/alchemy/configuration_methods.rb
alchemy_cms-7.2.1 lib/alchemy/configuration_methods.rb