Class: Drudgery::Transformer
- Inherits:
-
Object
- Object
- Drudgery::Transformer
- Defined in:
- lib/drudgery/transformer.rb
Instance Method Summary collapse
-
#initialize ⇒ Transformer
constructor
A new instance of Transformer.
- #register(processor) ⇒ Object
- #transform(data) ⇒ Object
Constructor Details
#initialize ⇒ Transformer
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 |