Sha256: b0514d41c7cc22bd724404076ef27e41d24df696cd5dbb804e8d293bad639d87

Contents?: true

Size: 970 Bytes

Versions: 5

Compression:

Stored size: 970 Bytes

Contents

module Scenic
  module CommandRecorder
    # @api private
    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 remove_version
        StatementArguments.new([view, options_without_version])
      end

      def to_a
        @args.to_a.dup.delete_if(&:empty?)
      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

      def options_without_version
        options.except(:version)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
scenic-jets-1.5.5 lib/scenic/command_recorder/statement_arguments.rb
scenic-jets-1.5.4 lib/scenic/command_recorder/statement_arguments.rb
scenic-1.5.4 lib/scenic/command_recorder/statement_arguments.rb
scenic-1.5.3 lib/scenic/command_recorder/statement_arguments.rb
scenic-1.5.2 lib/scenic/command_recorder/statement_arguments.rb