class Smartdict::Translator::DriverConfiguration
Middleware
Public Class Methods
new(translator)
click to toggle source
# File lib/smartdict/translator/driver_configuration.rb, line 3 def initialize(translator) @translator = translator end
Public Instance Methods
call(word, opts)
click to toggle source
# File lib/smartdict/translator/driver_configuration.rb, line 7 def call(word, opts) unless opts[:driver] opts[:driver] = define_driver(opts[:from_lang], opts[:to_lang]) end @translator.call(word, opts) end
define_driver(from_lang, to_lang)
click to toggle source
# File lib/smartdict/translator/driver_configuration.rb, line 14 def define_driver(from_lang, to_lang) key = "#{from_lang}-#{to_lang}" conf = configatron.drivers conf.retrieve(key) || conf.retrieve(:default) || raise(Smartdict::Error.new("No default driver")) end