Sha256: 8147bd05848f17aee849b055cf7a41d126e94cc77d23091b822c88f9afe3a76f

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

module Scenic
  module ActiveRecord
    module CommandRecorder
      class StatementArguments
        def initialize(args)
          @args = args.freeze
        end

        def view
          @args[0]
        end

        def version
          options[:version]
        end

        def revert_to_version
          options[:revert_to_version]
        end

        def invert_version
          StatementArguments.new([view, options_for_revert])
        end

        def to_a
          @args.to_a
        end

        private

        def options
          @options ||= @args[1] || {}
        end

        def options_for_revert
          options.clone.tap do |revert_options|
            revert_options[:version] = revert_to_version
            revert_options.delete(:revert_to_version)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scenic-0.1.0 lib/scenic/active_record/command_recorder/statement_arguments.rb