Sha256: a732e9eda1165a11cbdada7afc1cf5c952d3351616208d397b529b59586354ac

Contents?: true

Size: 389 Bytes

Versions: 16

Compression:

Stored size: 389 Bytes

Contents

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 << nil if codes.length == 1
      find_by_language_code_and_country_code *codes
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
alchemy_cms-2.2.4 app/models/alchemy/language/code.rb
alchemy_cms-2.2.3.2 app/models/alchemy/language/code.rb
alchemy_cms-2.2.3.1 app/models/alchemy/language/code.rb
alchemy_cms-2.2.2 app/models/alchemy/language/code.rb
alchemy_cms-2.2.1 app/models/alchemy/language/code.rb
alchemy_cms-2.2.0 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc15 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc14 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc13 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc11 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc8 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc7 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc6 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc3 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc2 app/models/alchemy/language/code.rb
alchemy_cms-2.2.rc1 app/models/alchemy/language/code.rb