Sha256: 944d9ec577827feede115c73410358096e044a7da55d440e5a53e42a778875e1

Contents?: true

Size: 1.42 KB

Versions: 10

Compression:

Stored size: 1.42 KB

Contents

module RR
  module DoubleDefinitions
    module Strategies
      class Strategy
        attr_reader :double_definition_create
        attr_reader :definition
        attr_reader :method_name
        attr_reader :args
        attr_reader :kwargs
        attr_reader :handler

        include Space::Reader

        def initialize(double_definition_create)
          @double_definition_create = double_definition_create
        end

        def call(definition, method_name, args, kwargs, handler)
          @definition = definition
          @method_name = method_name
          @args = args
          @kwargs = kwargs
          @handler = handler
          do_call
        end

        def verify_subject(subject)
        end

      protected
        def do_call
          raise NotImplementedError
        end

        if KeywordArguments.fully_supported?
          def permissive_argument
            if args.empty? and kwargs.empty?
              definition.with_any_args
            else
              definition.with(*args, **kwargs)
            end
          end
        else
          def permissive_argument
            if args.empty?
              definition.with_any_args
            else
              definition.with(*args)
            end
          end
        end

        def reimplementation
          definition.returns(&handler)
        end

        def subject
          definition.subject
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rr-3.1.1 lib/rr/double_definitions/strategies/strategy.rb
rr-3.1.0 lib/rr/double_definitions/strategies/strategy.rb
rr-3.0.9 lib/rr/double_definitions/strategies/strategy.rb
rr-3.0.8 lib/rr/double_definitions/strategies/strategy.rb
rr-3.0.7 lib/rr/double_definitions/strategies/strategy.rb
rr-3.0.6 lib/rr/double_definitions/strategies/strategy.rb
rr-3.0.5 lib/rr/double_definitions/strategies/strategy.rb
rr-3.0.2 lib/rr/double_definitions/strategies/strategy.rb
rr-3.0.1 lib/rr/double_definitions/strategies/strategy.rb
rr-3.0.0 lib/rr/double_definitions/strategies/strategy.rb