Skip to content

Commit

Permalink
simplify argument check and add raising error for unexpected type
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed Mar 29, 2016
1 parent a63ee6c commit 4d29491
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/fluent/plugin_helper/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ def storage_create(usage: '', type: nil, conf: nil)
end
storage = Plugin.new_storage(type)
storage.owner = self
config = if conf && conf.is_a?(Fluent::Config::Element)
config = case conf
when Fluent::Config::Element
conf
elsif conf && conf.is_a?(Hash)
when Hash
conf = Hash[conf.map{|k,v| [k.to_s, v]}]
Fluent::Config::Element.new('storage', '', conf, [])
else
when nil
Fluent::Config::Element.new('storage', '', {}, [])
else
raise ArgumentError, "BUG: conf must be a Element, Hash (or unspecified), but '#{conf.class}'"
end
storage.configure(config)
s = @_storages[usage] = StorageState.new(wrap_instance(storage), false)
Expand Down

0 comments on commit 4d29491

Please sign in to comment.