Sha256: 56caf21fd140e6c154a75a998fafdba64b24333ffb543bb33cbfac02609cb238

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

require 'criteria_operator/exceptions'

module CriteriaOperator

  # Base class for all criteria operators. Provides operator overloads and other
  # useful utility and convenience functions.
  # @abstract Subclass and override {#clone} to implement.
  class BaseOperator

    # Clones an operator with all sub-operators, creating a deep copy.
    # @abstract
    # @return [BaseOperator] the cloned operator
    def clone
      raise NotImplementedError
    end

    protected

    # Clones the passed operator if it isn't nil.
    # @param [BaseOperator] op the operator to clone
    # @return [BaseOperator, nil] The cloned base operator, if it exists, or nil, otherwise.
    def clone_or_nil(op)
      return nil if op.nil? || !op.is_a?(BaseOperator)
      op.clone
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
criteria_operator-0.2.0 lib/criteria_operator/base_operator.rb