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.



11
12
13
14
15
16
17
# File 'lib/dap/filter/simple.rb', line 11

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



19
20
21
22
23
24
25
26
27
# File 'lib/dap/filter/simple.rb', line 19

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