Sha256: b00bbffbdc9d196942a54f9dc199d399b1096f9886466268fed6cae135c53202

Contents?: true

Size: 886 Bytes

Versions: 6

Compression:

Stored size: 886 Bytes

Contents

class RemoteTable
  class Transformer
    attr_reader :t
    def initialize(t)
      @t = t
      @legacy_transformer_mutex = ::Mutex.new
    end
    # eventually this will support a different way of specifying a transformer
    def transform(row)
      if legacy_transformer
        ::Array.wrap legacy_transformer.apply(row)
      else
        [row]
      end
    end
    def legacy_transformer
      return @legacy_transformer[0] if @legacy_transformer.is_a?(::Array)
      @legacy_transformer_mutex.synchronize do
        return @legacy_transformer[0] if @legacy_transformer.is_a?(::Array)
        memo = if (transform_settings = t.transform_settings)
          transform_settings = transform_settings.symbolize_keys
          transform_settings[:class].new transform_settings.except(:class)
        end
        @legacy_transformer = [memo]
        memo
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
remote_table-2.1.2 lib/remote_table/transformer.rb
remote_table-2.1.1 lib/remote_table/transformer.rb
remote_table-2.1.0 lib/remote_table/transformer.rb
remote_table-2.0.2 lib/remote_table/transformer.rb
remote_table-2.0.1 lib/remote_table/transformer.rb
remote_table-2.0.0 lib/remote_table/transformer.rb