Sha256: c7337f682a731ec1c40c3d657246890115e9d0ad48219891a0e7164758f515a1

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Shiyo
  # The mixin module that provides basic methods to implement user specifications.
  module Specification
    # Composes a Spec::And specification of self and the other specification.
    #
    # @param other [Shiyo::Specification] A specification object to combine with self.
    # @return [Shiyo::And] The composed specification.
    def and(other)
      Shiyo::And.new(self, other)
    end

    # Composes a Spec::Or specification of self and the other specification.
    #
    # @param other [Shiyo::Specification] A specification object to combine with self.
    # @return [Shiyo::Or] The composed specification.
    def or(other)
      Shiyo::Or.new(self, other)
    end

    # Inspects whether the candidate satisfies the the specification.
    # This method must be overridden by the class that includes this module.
    #
    # @param candidate [Object] The candidate object to be inspected.
    # @return [void]
    # @raise [NotImplementedError]
    def satisfied_by?(_candidate)
      raise NotImplementedError, "Implement your inspection code."
    end

    def to_shiyo
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shiyo-0.1.2 lib/shiyo/specification.rb
shiyo-0.1.1 lib/shiyo/specification.rb
shiyo-0.1.0 lib/shiyo/specification.rb