最近、自家製の構成モジュールを Configatron に置き換えましたが、1 つのユース ケースを機能させることができません。
configatron 値を Object.const_get の引数として使用しようとすると、次のようになります。
def formatter_class
Object.const_get(configatron.formatter)
end
次のエラーが表示されます。
file.rb:10:in `const_get': can't convert Configatron::Store to String
(Configatron::Store#to_str gives Configatron::Store) (TypeError)
configatron の割り当ては次のようになります (簡略化)。
configatron.formatter = case
when condition?
'ExportFormat'
else
'ScreenFormat'
end
してもconfigatron.formatter = 'ScreenFormat'
、同じエラーが発生します。
私もformatter_class
方法のバリエーションを試しました。これは失敗します:
def formatter_class
Object.const_get(configatron['formatter'])
end
もちろん、これは成功しますが、私のユースケースには当てはまりません:
def formatter_class
Object.const_get('ScreenFormat')
end
私は何を間違っていますか?