Sha256: 78c26f70eaf29396e31d363ea539d0a8453608c0dbc1322aefb760e1ad73cf4a

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

Contents

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)
      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

16 entries across 16 versions & 1 rubygems

Version Path
alchemy_cms-3.6.7 lib/alchemy/configuration_methods.rb
alchemy_cms-3.6.6 lib/alchemy/configuration_methods.rb
alchemy_cms-3.6.5 lib/alchemy/configuration_methods.rb
alchemy_cms-3.6.4 lib/alchemy/configuration_methods.rb
alchemy_cms-3.6.3 lib/alchemy/configuration_methods.rb
alchemy_cms-3.6.2 lib/alchemy/configuration_methods.rb
alchemy_cms-3.6.1 lib/alchemy/configuration_methods.rb
alchemy_cms-4.0.0.beta lib/alchemy/configuration_methods.rb
alchemy_cms-3.6.0 lib/alchemy/configuration_methods.rb
alchemy_cms-3.5.0 lib/alchemy/configuration_methods.rb
alchemy_cms-3.4.2 lib/alchemy/configuration_methods.rb
alchemy_cms-3.5.0.rc2 lib/alchemy/configuration_methods.rb
alchemy_cms-3.5.0.rc1 lib/alchemy/configuration_methods.rb
alchemy_cms-3.4.1 lib/alchemy/configuration_methods.rb
alchemy_cms-3.4.0 lib/alchemy/configuration_methods.rb
alchemy_cms-3.4.0.rc1 lib/alchemy/configuration_methods.rb