Sha256: 23733bef67cfa147138ef7052af86ea35c29c3424e432553ad92394649cb20a7

Contents?: true

Size: 1.77 KB

Versions: 5

Compression:

Stored size: 1.77 KB

Contents

# encoding: utf-8
class MagicLocales::Language < ActiveRecord::Base
  
  # =====> R E W R I T E S <================================================================= #
  MODEL_PARAMS = [ :id, :locale_id, :level, :_destroy ]
  
  # =====> C O N S T A N T S <=============================================================== #
  LEVELS = %w(basic medium advanced excelent) # => and 'native'
  
  # =====> A S S O Z I A T I O N S <========================================================= #
  belongs_to :owner,    polymorphic: true
  belongs_to :locale,   class_name: "MagicLocales::Locale",   foreign_key: :locale_id
  
  
  # =====> A T T R I B U T E S <============================================================= #
  delegate   :name, :iso_code, to: :locale, allow_nil: true
  
  
  # =====> V A L I D A T I O N <============================================================= #
  validates :locale, presence: true
  
  
  # =====> C A L L B A C K S <=============================================================== #
  # before_validation :clean_up_values
  
  
  # =====> S C O P E S <===================================================================== #
  
  # =====> C L A S S - M E T H O D S <======================================================= #
  
  # =====> I N S T A N C E - M E T H O D S <================================================= #
  
  # =====>  P  R  I  V  A  T  E  !  <======================================================== # # # # # # # #
private
  
  # def clean_up_values
  #   if self.iso_code.present? && self.iso_code_changed?
  #     self.iso_code = if self.iso_code.split("-").count > 1
  #       "#{self.iso_code.split("-")[0].to_s.downcase}-#{self.iso_code.split("-")[1].to_s.upcase}"
  #     else
  #       self.iso_code.to_s.downcase
  #     end
  #   end
  # end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
magic_locales-0.0.21 lib/app/models/magic_locales/language.rb
magic_locales-0.0.20 lib/app/models/magic_locales/language.rb
magic_locales-0.0.19 lib/app/models/magic_locales/language.rb
magic_locales-0.0.18 lib/app/models/magic_locales/language.rb
magic_locales-0.0.17 lib/app/models/magic_locales/language.rb