Sha256: 045386a67fa890032bc0dd7557fb00225da527966808e496623541f0729472ec

Contents?: true

Size: 462 Bytes

Versions: 4

Compression:

Stored size: 462 Bytes

Contents

ActiveRecord::Base.class_eval do
  def in_any_locale?(attribute)
    I18n.available_locales.any?{|locale| send(self.class.localized_attr_name_for(attribute, locale)).present?}
  end

  def any_of?(*attributes)
    translated, untranslated = attributes.partition{|attribute| self.class.translated_attribute_names.include?(attributes)}
    translated.any?{|attribute| in_any_locale?(attribute)} || untranslated.any?{|attribute| self[attribute].present?}
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
citizen_budget_model-0.0.4 config/initializers/active_record.rb
citizen_budget_model-0.0.3 config/initializers/active_record.rb
citizen_budget_model-0.0.2 config/initializers/active_record.rb
citizen_budget_model-0.0.1 config/initializers/active_record.rb