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.0.0.pre.rc1 app/models/alchemy/language/code.rb
alchemy_cms-6.0.0.pre.b6 app/models/alchemy/language/code.rb
alchemy_cms-6.0.0.pre.b5 app/models/alchemy/language/code.rb
alchemy_cms-6.0.0.pre.b4 app/models/alchemy/language/code.rb
alchemy_cms-6.0.0.b3 app/models/alchemy/language/code.rb
alchemy_cms-6.0.0.b2 app/models/alchemy/language/code.rb
alchemy_cms-6.0.0.b1 app/models/alchemy/language/code.rb
alchemy_cms-5.2.1 app/models/alchemy/language/code.rb
alchemy_cms-5.1.4 app/models/alchemy/language/code.rb
alchemy_cms-5.0.4 app/models/alchemy/language/code.rb
alchemy_cms-5.1.3 app/models/alchemy/language/code.rb
alchemy_cms-5.2.0 app/models/alchemy/language/code.rb
alchemy_cms-5.2.0.rc1 app/models/alchemy/language/code.rb
alchemy_cms-5.2.0.b1 app/models/alchemy/language/code.rb
alchemy_cms-5.1.2 app/models/alchemy/language/code.rb
alchemy_cms-5.1.1 app/models/alchemy/language/code.rb
alchemy_cms-5.0.3 app/models/alchemy/language/code.rb
alchemy_cms-5.1.0 app/models/alchemy/language/code.rb
alchemy_cms-5.0.2 app/models/alchemy/language/code.rb
alchemy_cms-5.1.0.rc1 app/models/alchemy/language/code.rb