Sha256: 118716af192d6cbf69eba1a8dd43bc8c5fff7d36239ef209b0f60a557dbccbac

Contents?: true

Size: 389 Bytes

Versions: 6

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alchemy_cms-3.3.3 app/models/alchemy/language/code.rb
alchemy_cms-3.3.2 app/models/alchemy/language/code.rb
alchemy_cms-3.3.1 app/models/alchemy/language/code.rb
alchemy_cms-3.3.0 app/models/alchemy/language/code.rb
alchemy_cms-3.3.0.rc2 app/models/alchemy/language/code.rb
alchemy_cms-3.3.0.rc1 app/models/alchemy/language/code.rb