Method: Traject::TranslationMap#initialize

Defined in:
lib/traject/translation_map.rb

#initialize(defn, options = {}) ⇒ TranslationMap

Returns a new instance of TranslationMap.



169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/traject/translation_map.rb', line 169

def initialize(defn, options = {})
  if defn.kind_of? Hash
    @hash = defn
  else
    @hash = self.class.cache.lookup(defn)
    raise NotFound.new(defn) if @hash.nil?
  end

  if options[:default]
    @default = options[:default]
  elsif @hash.has_key? "__default__"
    @default = @hash["__default__"]
  end
end