Class: Dap::Filter::FilterRename

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

Constructor Details

#initialize(args) ⇒ FilterRename

Returns a new instance of FilterRename.



25
26
27
28
29
30
31
# File 'lib/dap/filter/simple.rb', line 25

def initialize(args)
  super
  missing_rename = self.opts.select { |k, v| v.nil? }.keys
  unless missing_rename.empty?
    fail "Missing new name for renames of #{missing_rename.join(',')}"
  end
end

Instance Method Details

#process(doc) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/dap/filter/simple.rb', line 33

def process(doc)
  self.opts.each_pair do |k,v|
    if doc.has_key?(k)
      doc[v] = doc[k]
      doc.delete(k)
    end
  end
 [ doc ]
end