Sha256: 5f78b1219d47a32c057509a561ecfa66f3bd2cc0fcc544c3f4197b21ee1a85ed

Contents?: true

Size: 470 Bytes

Versions: 47

Compression:

Stored size: 470 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

47 entries across 47 versions & 1 rubygems

Version Path
alchemy_cms-7.3.4 app/models/alchemy/language/code.rb
alchemy_cms-7.3.3 app/models/alchemy/language/code.rb
alchemy_cms-7.3.2 app/models/alchemy/language/code.rb
alchemy_cms-7.2.7 app/models/alchemy/language/code.rb
alchemy_cms-7.3.1 app/models/alchemy/language/code.rb
alchemy_cms-7.3.0 app/models/alchemy/language/code.rb
alchemy_cms-7.2.6 app/models/alchemy/language/code.rb
alchemy_cms-7.2.5 app/models/alchemy/language/code.rb
alchemy_cms-7.1.12 app/models/alchemy/language/code.rb
alchemy_cms-7.0.15 app/models/alchemy/language/code.rb
alchemy_cms-7.2.4 app/models/alchemy/language/code.rb
alchemy_cms-7.1.11 app/models/alchemy/language/code.rb
alchemy_cms-7.2.3 app/models/alchemy/language/code.rb
alchemy_cms-7.1.10 app/models/alchemy/language/code.rb
alchemy_cms-7.2.2 app/models/alchemy/language/code.rb
alchemy_cms-7.1.9 app/models/alchemy/language/code.rb
alchemy_cms-7.0.14 app/models/alchemy/language/code.rb
alchemy_cms-7.2.1 app/models/alchemy/language/code.rb
alchemy_cms-7.0.13 app/models/alchemy/language/code.rb
alchemy_cms-7.1.8 app/models/alchemy/language/code.rb