Sha256: 9c29a5b7f7a93354759802477a45e4d2e21d245622b314d0c0e679ecb10bc18f

Contents?: true

Size: 471 Bytes

Versions: 88

Compression:

Stored size: 471 Bytes

Contents

# frozen_string_literal: true

module Alchemy::Language::Code
  extend ActiveSupport::Concern

  def code
    [language_code, country_code].select(&:present?).join("-")
  end

  def code=(code)
    self.language_code = code
  end

  module ClassMethods
    def find_by_code(code)
      codes = code.split("-")
      codes << "" if codes.length == 1
      on_current_site.find_by(
        language_code: codes[0],
        country_code: codes[1],
      )
    end
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
alchemy_cms-6.1.10 app/models/alchemy/language/code.rb
alchemy_cms-6.1.9 app/models/alchemy/language/code.rb
alchemy_cms-6.1.8 app/models/alchemy/language/code.rb
alchemy_cms-6.1.7 app/models/alchemy/language/code.rb
alchemy_cms-6.1.6 app/models/alchemy/language/code.rb
alchemy_cms-6.1.5 app/models/alchemy/language/code.rb
alchemy_cms-6.0.14 app/models/alchemy/language/code.rb
alchemy_cms-6.1.4 app/models/alchemy/language/code.rb
alchemy_cms-7.0.0.pre.a app/models/alchemy/language/code.rb
alchemy_cms-6.0.13 app/models/alchemy/language/code.rb
alchemy_cms-6.1.3 app/models/alchemy/language/code.rb
alchemy_cms-6.1.2 app/models/alchemy/language/code.rb
alchemy_cms-6.1.1 app/models/alchemy/language/code.rb
alchemy_cms-6.1.0 app/models/alchemy/language/code.rb
alchemy_cms-6.0.12 app/models/alchemy/language/code.rb
alchemy_cms-6.0.11 app/models/alchemy/language/code.rb
alchemy_cms-6.0.10 app/models/alchemy/language/code.rb
alchemy_cms-5.3.8 app/models/alchemy/language/code.rb
alchemy_cms-6.0.9 app/models/alchemy/language/code.rb
alchemy_cms-5.3.7 app/models/alchemy/language/code.rb