module RailsConnector class DictStorage #:nodoc: all class << self def configure(config) @config = config.present? ? config.symbolize_keys : {} end def get(spec) storage.get(spec) end private attr_reader :config def storage @storage ||= case config[:type] when "s3" s3_storage(config) when "file" file_storage(config) else raise "Unsupported dict storage type #{config[:type]}" end end def s3_storage(config) bucket = AWS::S3.new(config).buckets[config[:bucket_name]] Kvom::Storage::S3Storage.new({ :bucket => bucket, :bucket_prefix => "dict", :cache => s3_storage_cache, :cache_prefix => "dict.", }) end def s3_storage_cache Rails.cache end def file_storage(config) Kvom::Storage::FileSystemStorage.new(config) end end end end