Class: ATP::Processors::Marshal

Inherits:
ATP::Processor show all
Defined in:
lib/atp/processors/marshal.rb

Overview

Makes the AST safe for Marshaling

Instance Method Summary collapse

Methods inherited from ATP::Processor

#clean_flag, #extract_volatiles, #handler_missing, #process, #process_all, #run, #volatile?, #volatile_flags

Instance Method Details

#on_object(node) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/atp/processors/marshal.rb', line 5

def on_object(node)
  o = node.value
  if o.is_a?(String)
    node.updated(nil, [{ 'Test' => o }])
  elsif o.is_a?(Hash)
    node.updated(nil, [o])
  elsif o.respond_to?(:to_meta) && o.to_meta && !o.to_meta.empty?
    node.updated(nil, [o.to_meta])
  else
    meta = { 'Test' => o.name }
    meta['Pattern'] = o.try(:pattern)
    node.updated(nil, [meta])
  end
end

#on_render(node) ⇒ Object



20
21
22
# File 'lib/atp/processors/marshal.rb', line 20

def on_render(node)
  node.updated(nil, [node.value.to_s])
end