Sha256: 06bf97e4ab3e5816b576a5339cc0705ab577362d56fa73831f73dd81a4e40b51

Contents?: true

Size: 839 Bytes

Versions: 26

Compression:

Stored size: 839 Bytes

Contents

module Kuhsaft
  module Translatable

    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def translate *args
        args.each do |attr_name|
          define_method attr_name do
            send "#{attr_name}_#{I18n.locale}"
          end

          define_method "#{attr_name}?" do
            send "#{attr_name}_#{I18n.locale}?"
          end

          define_method "#{attr_name}=" do |val|
            send "#{attr_name}_#{I18n.locale}=", val
          end

          define_method "find_by_#{attr_name}" do |val|
            send "find_by_#{attr_name}_#{I18n.locale}", val
          end
        end
      end

      def locale_attr attr_name
        "#{attr_name}_#{I18n.locale}"
      end
    end

    def locale_attr attr_name
      "#{attr_name}_#{I18n.locale}"
    end


  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
kuhsaft-1.4.2 lib/kuhsaft/translatable.rb
kuhsaft-1.4.1 lib/kuhsaft/translatable.rb
kuhsaft-1.4.0 lib/kuhsaft/translatable.rb
kuhsaft-1.3.1 lib/kuhsaft/translatable.rb
kuhsaft-1.2.15 lib/kuhsaft/translatable.rb
kuhsaft-1.2.14 lib/kuhsaft/translatable.rb
kuhsaft-1.2.13 lib/kuhsaft/translatable.rb
kuhsaft-1.2.12 lib/kuhsaft/translatable.rb
kuhsaft-1.2.11 lib/kuhsaft/translatable.rb
kuhsaft-1.2.10 lib/kuhsaft/translatable.rb
kuhsaft-1.2.9 lib/kuhsaft/translatable.rb
kuhsaft-1.2.8 lib/kuhsaft/translatable.rb
kuhsaft-1.2.7 lib/kuhsaft/translatable.rb
kuhsaft-1.2.6 lib/kuhsaft/translatable.rb
kuhsaft-1.2.5 lib/kuhsaft/translatable.rb
kuhsaft-1.2.4 lib/kuhsaft/translatable.rb
kuhsaft-1.2.3 lib/kuhsaft/translatable.rb
kuhsaft-1.2.2 lib/kuhsaft/translatable.rb
kuhsaft-1.2.1 lib/kuhsaft/translatable.rb
kuhsaft-1.2.0 lib/kuhsaft/translatable.rb