Sha256: 69f51995ea371b001ef038bf7a25f6382c867e74a4c858e82b6bee5cfdfb7dce

Contents?: true

Size: 706 Bytes

Versions: 31

Compression:

Stored size: 706 Bytes

Contents

module Mobility
  module Backends
=begin

Backend which stores translations in an in-memory hash.

=end
    class Hash
      include Backend

      # @!group Backend Accessors
      # @!macro backend_reader
      # @return [Object]
      def read(locale, _ = {})
        translations[locale]
      end

      # @!macro backend_writer
      # @return [Object]
      def write(locale, value, _ = {})
        translations[locale] = value
      end
      # @!endgroup

      # @!macro backend_iterator
      def each_locale
        translations.each { |l, _| yield l }
      end

      private

      def translations
        @translations ||= {}
      end
    end

    register_backend(:hash, Hash)
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
mobility-1.3.1 lib/mobility/backends/hash.rb
mobility-1.3.0 lib/mobility/backends/hash.rb
mobility-1.3.0.rc3 lib/mobility/backends/hash.rb
mobility-1.3.0.rc2 lib/mobility/backends/hash.rb
mobility-1.3.0.rc1 lib/mobility/backends/hash.rb
mobility-1.2.9 lib/mobility/backends/hash.rb
mobility-1.2.8 lib/mobility/backends/hash.rb
mobility-1.2.7 lib/mobility/backends/hash.rb
mobility-1.2.6 lib/mobility/backends/hash.rb
mobility-1.2.5 lib/mobility/backends/hash.rb
mobility-1.2.4 lib/mobility/backends/hash.rb
mobility-1.2.3 lib/mobility/backends/hash.rb
mobility-1.2.2 lib/mobility/backends/hash.rb
mobility-1.2.1 lib/mobility/backends/hash.rb
mobility-1.2.0 lib/mobility/backends/hash.rb
mobility-1.1.3 lib/mobility/backends/hash.rb
mobility-1.1.2 lib/mobility/backends/hash.rb
mobility-1.1.1 lib/mobility/backends/hash.rb
mobility-1.1.0 lib/mobility/backends/hash.rb
mobility-1.0.7 lib/mobility/backends/hash.rb