Sha256: 13a8324cf9e0f50f74300637f27e7c40c81c05121e5c835bfaca32e00a6dc2c1

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

module Locomotive::Steam
  module Models

    class I18nField

      extend Forwardable

      def_delegators :@translations, :values, :blank?

      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 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.3 lib/locomotive/steam/models/i18n_field.rb
locomotivecms_steam-1.0.0.pre.alpha.2 lib/locomotive/steam/models/i18n_field.rb