Sha256: 749b0e076911e7ffd1d412c53b2c54ada0304b4441bfec02e5d37e42364b091d

Contents?: true

Size: 749 Bytes

Versions: 3

Compression:

Stored size: 749 Bytes

Contents

module Scenic
  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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scenic-0.3.0 lib/scenic/command_recorder/statement_arguments.rb
scenic-0.2.1 lib/scenic/command_recorder/statement_arguments.rb
scenic-0.2.0 lib/scenic/command_recorder/statement_arguments.rb