Sha256: 68d85b2a2b8a23f04401417cd949bb482fdcf678e2e1abeeedabda61d35c6542

Contents?: true

Size: 730 Bytes

Versions: 3

Compression:

Stored size: 730 Bytes

Contents

module Lit
  class Locale < ActiveRecord::Base

    ## SCOPES
    scope :ordered, proc{ order('locale ASC') }

    ## ASSOCIATIONS
    has_many :localizations, :dependent=>:destroy

    ## VALIDATIONS
    validates :locale,
              :presence=>true,
              :uniqueness=>true

    if ::Rails::VERSION::MAJOR<4
      ## ACCESSIBLE
      attr_accessible :locale
    end

    def to_s
      self.locale
    end

    def get_translated_percentage
      self.get_changed_localizations_count * 100 / self.get_all_localizations_count
    end

    def get_changed_localizations_count
      self.localizations.changed.count(:id)
    end

    def get_all_localizations_count
      self.localizations.count(:id)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lit-0.0.4.2 app/models/lit/locale.rb
lit-0.0.4.1 app/models/lit/locale.rb
lit-0.0.4 app/models/lit/locale.rb