Sha256: f69701028f2671e66f5985973197960783e1dfe8239c57fb07b377edb0260d41

Contents?: true

Size: 1.07 KB

Versions: 123

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 = Language.current&.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

123 entries across 123 versions & 1 rubygems

Version Path
alchemy_cms-5.2.5 lib/alchemy/configuration_methods.rb
alchemy_cms-5.1.9 lib/alchemy/configuration_methods.rb
alchemy_cms-5.0.9 lib/alchemy/configuration_methods.rb
alchemy_cms-5.2.4 lib/alchemy/configuration_methods.rb
alchemy_cms-5.1.8 lib/alchemy/configuration_methods.rb
alchemy_cms-5.0.8 lib/alchemy/configuration_methods.rb
alchemy_cms-5.0.7 lib/alchemy/configuration_methods.rb
alchemy_cms-5.1.7 lib/alchemy/configuration_methods.rb
alchemy_cms-5.2.3 lib/alchemy/configuration_methods.rb
alchemy_cms-6.0.0.pre.rc2 lib/alchemy/configuration_methods.rb
alchemy_cms-5.1.6 lib/alchemy/configuration_methods.rb
alchemy_cms-5.0.6 lib/alchemy/configuration_methods.rb
alchemy_cms-5.2.2 lib/alchemy/configuration_methods.rb
alchemy_cms-5.1.5 lib/alchemy/configuration_methods.rb
alchemy_cms-5.0.5 lib/alchemy/configuration_methods.rb
alchemy_cms-6.0.0.pre.rc1 lib/alchemy/configuration_methods.rb
alchemy_cms-6.0.0.pre.b6 lib/alchemy/configuration_methods.rb
alchemy_cms-6.0.0.pre.b5 lib/alchemy/configuration_methods.rb
alchemy_cms-6.0.0.pre.b4 lib/alchemy/configuration_methods.rb
alchemy_cms-6.0.0.b3 lib/alchemy/configuration_methods.rb