Sha256: 00787620e732858bc8aed32786c9bc50d36f6b6be5f639027eee34f25754decd

Contents?: true

Size: 1.56 KB

Versions: 7

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

require_relative "arguments/null_arguments"

module ConvenientService
  module Support
    class Arguments
      ##
      # @!attribute [r] args
      #   @return [Array]
      #
      attr_reader :args

      ##
      # @!attribute [r] kwargs
      #   @return [Hash]
      #
      attr_reader :kwargs

      ##
      # @!attribute [r] block
      #   @return [Proc]
      #
      attr_reader :block

      ##
      # @param args [Array]
      # @param kwargs [Hash]
      # @param block [Proc]
      # @return [void]
      #
      def initialize(*args, **kwargs, &block)
        @args = args
        @kwargs = kwargs
        @block = block
      end

      class << self
        ##
        # @return [ConvenientService::Support::Arguments::NullArguments]
        #
        def null_arguments
          @null_arguments ||= Support::Arguments::NullArguments.new
        end
      end

      ##
      # @return [Boolean]
      #
      def null_arguments?
        false
      end

      ##
      # @return [Booleam]
      #
      def any?
        return true if args.any?
        return true if kwargs.any?
        return true if block

        false
      end

      ##
      # @return [Booleam]
      #
      def none?
        !any?
      end

      ##
      # @param other [Object]
      # @return [Boolean]
      #
      def ==(other)
        return unless other.instance_of?(self.class)

        return false if args != other.args
        return false if kwargs != other.kwargs
        return false if block != other.block

        true
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
convenient_service-0.11.0 lib/convenient_service/support/arguments.rb
convenient_service-0.10.1 lib/convenient_service/support/arguments.rb
convenient_service-0.10.0 lib/convenient_service/support/arguments.rb
convenient_service-0.9.0 lib/convenient_service/support/arguments.rb
convenient_service-0.8.0 lib/convenient_service/support/arguments.rb
convenient_service-0.7.0 lib/convenient_service/support/arguments.rb
convenient_service-0.6.0 lib/convenient_service/support/arguments.rb