Sha256: 3fdb017a58e3f1b56b0805b8dcebb3294ff1a0119fd0510aed1b436b7878ce48
Contents?: true
Size: 1.21 KB
Versions: 21
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Mobility module Backends =begin Defines read and write methods that access the value at a key with value +locale+ on a +translations+ hash. =end module HashValued # @!method column_affix # Returns interpolation string used to generate column names. # @return [String] Affix to generate column names # @!group Backend Accessors # # @!macro backend_reader def read(locale, _options = nil) translations[locale] end # @!macro backend_writer def write(locale, value, _options = nil) translations[locale] = value end # @!endgroup # @!macro backend_iterator def each_locale translations.each { |l, _| yield l } end def self.included(backend_class) backend_class.extend ClassMethods backend_class.option_reader :column_affix end module ClassMethods def configure(options) options[:column_affix] = "#{options[:column_prefix]}%s#{options[:column_suffix]}" end end private def column_name @column_name ||= (column_affix % attribute) end end private_constant :HashValued end end
Version data entries
21 entries across 21 versions & 1 rubygems