Sha256: a99e6dbec0cc88a58ed7d4a05c3e4198b0ad8f3a7379d21d6bcffdc738f16eec

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

# rubocop:disable Naming/MethodName
# rubocop:disable Naming/UncommunicativeMethodParamName
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/AbcSize

module Arel
  module Nodes
    # https://www.postgresql.org/docs/8.3/tutorial-transactions.html
    class Transaction < Arel::Nodes::Node
      attr_reader :type
      attr_reader :options

      def initialize(type, options)
        @type = type
        @options = options
      end
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_Transaction(o, collector)
        case o.type
        when 0
          collector << 'BEGIN'
        when 2
          collector << 'COMMIT'
        when 3
          collector << 'ROLLBACK'
        when 4
          collector << 'SAVEPOINT '
          collector << o.options.join(' ')
        when 5
          collector << 'RELEASE SAVEPOINT '
          collector << o.options.join(' ')
        when 6
          collector << 'ROLLBACK TO '
          collector << o.options.join(' ')
        else
          raise "Unknown transaction type `#{o.type}`"
        end
      end
    end
  end
end

# rubocop:enable Naming/MethodName
# rubocop:enable Naming/UncommunicativeMethodParamName
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/AbcSize

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arel_toolkit-0.3.0 lib/arel/extensions/transaction.rb