Sha256: c8e0de19eae26df7b2232ea9914fc3c56901540fd095b76ca717d63fae3f2af9

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

# encoding: utf-8

module Axiom
  class Function

    # A mixin for functions with directly compared operands
    module Comparable

      # Hook called when module is included
      #
      # @param [Module] descendant
      #   the module or class including Comparable
      #
      # @return [undefined]
      #
      # @api private
      def self.included(descendant)
        super
        descendant.extend(ClassMethods)
      end

      private_class_method :included

      module ClassMethods

        # Evaluate the values using the ruby operation
        #
        # @example
        #   function.call(left, right)  # => true or false
        #
        # @param [Object] left
        # @param [Object] right
        #
        # @return [Object]
        #
        # @api public
        def call(left, right)
          left.send(operation, right)
        end

      end # module Classmethods
    end # class Predicate
  end # class Function
end # module Axiom

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-0.1.1 lib/axiom/function/comparable.rb
axiom-0.1.0 lib/axiom/function/comparable.rb