Module: I18nAutoScoping::I18nExtension

Defined in:
lib/i18n_auto_scoping.rb

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/i18n_auto_scoping.rb', line 12

def self.included(mod)
  mod.class_eval do
    class << self
      alias_method :i18n_auto_scoping_backend=, :backend=
    
      def backend=(backend)
        r = send(:i18n_auto_scoping_backend=, backend)
        # When assigning a new backend, we try to extend it :
        extend_backend_for_i18n_auto_scoping
        r
      end

      def extend_backend_for_i18n_auto_scoping
        # Only extend the backend for auto scoping if it had not been already done
        if !backend.methods.include?('i18n_auto_scoping_translate')
          backend.extend ::I18nAutoScoping::BackendExtension
        end

      end
    end
  
  end
end