<commit_before>module Rack::RPC
  ##
  # Represents an RPC server operation.
  #
  class Operation
    ##
    # Defines an operand for this operation class.
    #
    # @example
    #   class Multiply < Operation
    #     operand :x, Numeric
    #     operand :y, Numeric
    #   end
    #
    # @param  [Symbol, #to_sym] name
    # @param  [Class] type
    # @param  [Hash{Symbol => Object}] options
    # @option options [Boolean] :optional (false)
    # @option options [Boolean] :nullable (false)
    # @return [void]
    def self.operand(name, type = Object, options = {})
      raise TypeError, "expected a Class, but got #{type.inspect}" unless type.is_a?(Class)
      @operands ||= {}
      @operands[name.to_sym] = options.merge(:type => type)
    end

    ##
    # Returns the arity range for this operation class.
    #
    # @return [Range]
    def self.arity
      @arity ||= begin
        if const_defined?(:ARITY)
          const_get(:ARITY)
        else
          min, max = 0, 0
          @operands ||= {}
          @operands.each do |name, options|
            min += 1 unless options[:optional].eql?(true)
            max += 1
          end
          Range.new(min, max)
        end
      end
    end

    ##
    # Executes this operation.
    #
    # @abstract
    # @return [void]
    def execute
      raise NotImplementedError, "#{self.class}#execute"
    end
  end # Operation
end # Rack::RPC<commit_msg>Implemented the Operation.operands class method.<commit_after>module Rack::RPC
  ##
  # Represents an RPC server operation.
  #
  class Operation
    ##
    # Defines an operand for this operation class.
    #
    # @example
    #   class Multiply < Operation
    #     operand :x, Numeric
    #     operand :y, Numeric
    #   end
    #
    # @param  [Symbol, #to_sym] name
    # @param  [Class] type
    # @param  [Hash{Symbol => Object}] options
    # @option options [Boolean] :optional (false)
    # @option options [Boolean] :nullable (false)
    # @return [void]
    def self.operand(name, type = Object, options = {})
      raise TypeError, "expected a Class, but got #{type.inspect}" unless type.is_a?(Class)
      operands[name.to_sym] = options.merge(:type => type)
    end

    ##
    # Returns the operand definitions for this operation class.
    #
    # @return [Hash{Symbol => Hash}]
    def self.operands
      @operands ||= {}
    end

    ##
    # Returns the arity range for this operation class.
    #
    # @return [Range]
    def self.arity
      @arity ||= begin
        if const_defined?(:ARITY)
          const_get(:ARITY)
        else
          min, max = 0, 0
          operands.each do |name, options|
            min += 1 unless options[:optional].eql?(true)
            max += 1
          end
          Range.new(min, max)
        end
      end
    end

    ##
    # Executes this operation.
    #
    # @abstract
    # @return [void]
    def execute
      raise NotImplementedError, "#{self.class}#execute"
    end
  end # Operation
end # Rack::RPC
{'fraction_non_alphanumeric': 0.11831173147224992, 'fraction_numerical': 0.0026586905948820204, 'mean_word_length': 2.052738336713996, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2195461', 'n_tokens_mistral': 942, 'n_tokens_neox': 941, 'n_words': 266}