Method: AnyStyle::Dictionary.create

Defined in:
lib/anystyle/dictionary.rb

.create(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/anystyle/dictionary.rb', line 20

def create(options = {})
  return options if options.is_a?(Dictionary)

  options = defaults.merge(options || {})
  adapter = options.delete :adapter

  case adapter.to_sym
  when :memory, :hash
    new options
  when :gdbm
    require 'anystyle/dictionary/gdbm'
    Dictionary::GDBM.new options
  when :lmdb
    require 'anystyle/dictionary/lmdb'
    Dictionary::LMDB.new options
  when :redis
    require 'anystyle/dictionary/redis'
    Dictionary::Redis.new options
  when :marshal, :ruby
    require 'anystyle/dictionary/marshal'
    Dictionary::Marshal.new options
  else
    raise ArgumentError, "unknown adapter: #{adapter}"
  end
end