Sha256: 628b1b8076f2b44f82597430d3250e66bee8df995b5caa36cecedca61b1fbb28

Contents?: true

Size: 651 Bytes

Versions: 12

Compression:

Stored size: 651 Bytes

Contents

module ATP
  module Processors
    # Makes the AST safe for Marshaling
    class Marshal < Processor
      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

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
atp-1.1.3 lib/atp/processors/marshal.rb
atp-1.1.2 lib/atp/processors/marshal.rb
atp-1.1.1 lib/atp/processors/marshal.rb
atp-1.1.0 lib/atp/processors/marshal.rb
atp-1.0.0 lib/atp/processors/marshal.rb
atp-0.8.0 lib/atp/processors/marshal.rb
atp-0.7.0 lib/atp/processors/marshal.rb
atp-0.6.0 lib/atp/processors/marshal.rb
atp-0.5.4 lib/atp/processors/marshal.rb
atp-0.5.3 lib/atp/processors/marshal.rb
atp-0.5.0 lib/atp/processors/marshal.rb
atp-0.4.3 lib/atp/processors/marshal.rb