Sha256: 208534eda305cf8892c1aa3157396799b186397ac77e1cc4319c9243c26c5ed8

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8

module Axiom

  # Abstract base class for logical functions
  class Function
    include AbstractType, Adamantium, Visitable

    abstract_singleton_method :call
    abstract_method :rename, :type

    # Rename the attribute(s) inside the function
    #
    # @param [Function] operand
    #
    # @param [Algebra::Rename::Aliases] aliases
    #
    # @return [Function]
    #
    # @todo simplify once Attribute#rename works the same as Function#rename
    #
    # @api private
    def self.rename_attributes(operand, aliases)
      if operand.respond_to?(:rename) && ! operand.kind_of?(Attribute)
        operand.rename(aliases)
      else
        aliases[operand]
      end
    end

    # Extract the value from the operand or tuple
    #
    # @param [Object, #call] operand
    #   the operand to extract the value from
    # @param [Tuple] tuple
    #   the tuple to pass in to the operand if it responds to #call
    #
    # @return [Object]
    #
    # @api private
    def self.extract_value(operand, tuple)
      operand.respond_to?(:call) ? operand.call(tuple) : operand
    end

  end # class Function
end # module Axiom

Version data entries

1 entries across 1 versions & 1 rubygems

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