Module: ActiveRecord::Validations

Included in:
Base
Defined in:
lib/gettext_activerecord/validations.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.append_features_with_gettext_activerecord(base) ⇒ Object

Since rails-1.2.0.



59
60
61
62
63
64
# File 'lib/gettext_activerecord/validations.rb', line 59

def append_features_with_gettext_activerecord(base) # :nodoc:
  unless base <= ActiveRecord::Base
    append_features_without_gettext_activerecord(base)
  end
  real_included(base)
end

.included_with_gettext_activerecord(base) ⇒ Object

:nodoc:



48
49
50
51
52
53
# File 'lib/gettext_activerecord/validations.rb', line 48

def included_with_gettext_activerecord(base) # :nodoc:
  unless base <= ActiveRecord::Base
    included_without_gettext_activerecord(base)
  end
  real_included(base)
end

.real_included(base) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gettext_activerecord/validations.rb', line 25

def real_included(base)
  base.extend ClassMethods
  base.class_eval{
    include GetText
    def gettext(str)  #:nodoc:
      _(str)
    end
    class << self
      def human_attribute_name_with_gettext_activerecord(attribute_key_name) #:nodoc:
        s_("#{self.to_s_with_gettext}|#{attribute_key_name.humanize}")
      end
      alias_method_chain :human_attribute_name, :gettext_activerecord

      def human_attribute_table_name_for_error(table_name) #:nodoc:
        _(table_name.gsub(/_/, " "))
      end
    end
  }
end