Class: Drudgery::Transformer

Inherits:
Object
  • Object
show all
Defined in:
lib/drudgery/transformer.rb

Instance Method Summary collapse

Constructor Details

#initializeTransformer

Returns a new instance of Transformer.



3
4
5
# File 'lib/drudgery/transformer.rb', line 3

def initialize
  @cache = {}
end

Instance Method Details

#register(processor) ⇒ Object



7
8
9
# File 'lib/drudgery/transformer.rb', line 7

def register(processor)
  @processor = processor
end

#transform(data) ⇒ Object



11
12
13
14
15
# File 'lib/drudgery/transformer.rb', line 11

def transform(data)
  symbolize_keys!(data)

  @processor ? @processor.call(data, @cache) : data
end