Class: Dap::Filter::FilterExpand

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/dap/filter/simple.rb

Instance Attribute Summary

Attributes included from Base

#name, #opts

Instance Method Summary collapse

Methods included from Base

#initialize

Instance Method Details

#process(doc) ⇒ Object



342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/dap/filter/simple.rb', line 342

def process(doc)
  new_doc = doc.clone
  self.opts.each_pair do |k,|
    k_re = /^#{k}\.(?<sub_key>.+)$/
    doc.each do |fk,fv|
      if md = k_re.match(fk)
        new_doc[k] ||= {}
        new_doc[k][md[:sub_key]] = fv
      end
    end
  end
 [ new_doc ]
end