lib/hedgelog/context.rb in hedgelog-0.1.5 vs lib/hedgelog/context.rb in hedgelog-0.1.6
- old
+ new
@@ -1,14 +1,16 @@
require 'hedgelog/scrubber'
+require 'hedgelog/normalizer'
class Hedgelog
class Context
- def initialize(scrubber, data = {})
+ def initialize(scrubber, normalizer, data = {})
raise ::ArgumentError, "#{self.class}: argument must be Hash got #{data.class}." unless data.is_a? Hash
check_reserved_keys(data)
@data = data
@scrubber = scrubber
+ @normalizer = normalizer
end
def []=(key, val)
raise ::ArgumentError, "#{self.class}: The #{key} is a reserved key and cannot be used." if Hedgelog::RESERVED_KEYS.include? key.to_sym
@@ -45,9 +47,14 @@
@data.merge!(hash_or_context)
end
def scrub!
@data = @scrubber.scrub(@data)
+ self
+ end
+
+ def normalize!
+ @data = @normalizer.normalize(@data)
self
end
def to_h
@data