Sha256: 2921b48435042a1cb08db25eef8019811d77f9a457908b32b4cb3829e01d759a

Contents?: true

Size: 766 Bytes

Versions: 2

Compression:

Stored size: 766 Bytes

Contents

module Locomotive::Steam
  module Models

    class I18nField

      attr_reader :name, :translations

      def initialize(name, translations)
        @name = name
        self.translations = translations
      end

      def [](locale)
        @translations[locale]
      end

      def []=(locale, value)
        @translations[locale] = value
      end

      def values
        @translations.values
      end

      def translations=(translations)
        @translations = (if translations.respond_to?(:fetch)
          translations
        else
          Hash.new { translations }
        end).with_indifferent_access
      end

      def each(&block)
        @translations.each(&block)
      end

      alias :__translations__ :translations

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/models/i18n_field.rb
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/models/i18n_field.rb